ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/ermyth/include/object.h
Revision: 1.3
Committed: Tue Aug 28 17:08:07 2007 UTC (16 years, 9 months ago) by pippijn
Content type: text/plain
Branch: MAIN
Changes since 1.2: +3 -3 lines
Log Message:
- changed name
- updated the example config to the new system
- added more documentation
- enhanced documentation generators
- added a link to the pdf to the website
- added an RSS feed generator
- transitioned hooks to c++ callbacks
- did various merges with upstream along the way
- added const where appropriate
- removed the old block allocator
- fixed most memory leaks
- transitioned some dictionaries to std::map
- transitioned some lists to std::vector
- made some free functions members where appropriate
- renamed string to dynstr and added a static string ststr
- use NOW instead of time (NULL) if possible
- completely reworked database backends, crypto handlers and protocol handlers
  to use an object factory
- removed the old module system. ermyth does not do any dynamic loading anymore
- fixed most of the build system
- reworked how protocol commands work

File Contents

# User Rev Content
1 pippijn 1.1 /*
2 pippijn 1.3 * Copyright © 2007 William Pitcock <nenolod -at- atheme.org>
3 pippijn 1.2 * Rights to this code are as documented in doc/pod/license.pod.
4 pippijn 1.1 *
5     * Object management.
6     *
7 pippijn 1.3 * $Id: object.h,v 1.2 2007-07-21 01:29:07 pippijn Exp $
8 pippijn 1.1 */
9    
10     #ifndef OBJECT_H
11     #define OBJECT_H
12    
13     /* object base class */
14     class object
15     {
16     mutable int refcnt;
17    
18     protected:
19     object ()
20     : refcnt (1)
21     {
22     }
23    
24     object (const object &other)
25     : refcnt (1)
26     {
27     }
28    
29     virtual ~object () { }
30     virtual void _destroy () = 0;
31    
32     public:
33     int refcnt_inc ()
34     {
35     return ++refcnt;
36     }
37    
38     int refcnt_dec ()
39     {
40     if (!--refcnt)
41     {
42     this->_destroy ();
43     return 0;
44     }
45     else
46     return refcnt;
47     }
48     };
49    
50     typedef void (*destructor_t) (void *);
51    
52 pippijn 1.3 struct object_t : zero_initialised
53 pippijn 1.1 {
54     char *name;
55     int refcount;
56     destructor_t destructor;
57     };
58    
59     E void object_init (object_t *, const char *name, destructor_t destructor);
60     E void *object_ref (void *);
61     E void object_unref (void *);
62    
63     #define asobject(x) ((object_t *) x)
64    
65     #endif