initial load of upstream version 1.06.32
[xmlrpc-c] / include / xmlrpc-c / girmem.hpp
1 #ifndef GIRMEM_HPP_INCLUDED
2 #define GIRMEM_HPP_INCLUDED
3
4
5 /* The following pthread crap mirrors what is in pthreadx.h, which is
6    what girmem.cpp uses to declare the lock interface.  We can't simply
7    include pthreadx.h here, because it's an internal Xmlrpc-c header file,
8    and this is an external one.
9
10    This is a stopgap measure until we do something cleaner, such as expose
11    pthreadx.h as an external interface (class girlock, maybe?) or create
12    a lock class with virtual methods.
13
14    The problem we're solving is that class autoObject contains 
15    a pthread_mutex_t member, and on Windows, there's no such type.
16 */
17    
18 #ifndef WIN32
19 #  include <pthread.h>
20    typedef pthread_mutex_t girmem_lock;
21 #else
22    typedef CRITICAL_SECTION girmem_lock;
23 #endif
24
25 namespace girmem {
26
27 class autoObjectPtr;
28
29 class autoObject {
30     friend class autoObjectPtr;
31
32 public:
33     void incref();
34     void decref(bool * const unreferencedP);
35     
36 protected:
37     autoObject();
38     virtual ~autoObject();
39
40 private:
41     girmem_lock refcountLock;
42     unsigned int refcount;
43 };
44
45 class autoObjectPtr {
46 public:
47     autoObjectPtr();
48     autoObjectPtr(girmem::autoObject * objectP);
49     autoObjectPtr(girmem::autoObjectPtr const& autoObjectPtr);
50     
51     ~autoObjectPtr();
52     
53     void
54     point(girmem::autoObject * const objectP);
55
56     void
57     unpoint();
58
59     autoObjectPtr
60     operator=(girmem::autoObjectPtr const& objectPtr);
61     
62     girmem::autoObject *
63     operator->() const;
64     
65     girmem::autoObject *
66     get() const;
67
68 protected:
69     girmem::autoObject * objectP;
70 };
71
72 } // namespace
73
74 #endif