OSDN Git Service

initial import
[molby/Molby.git] / MolLib / Object.h
1 /*
2  *  Object.h
3  *
4  *  Created by Toshi Nagata on 06/03/11.
5  *  Copyright 2006-2008 Toshi Nagata. All rights reserved.
6  *
7  This program is free software; you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation version 2 of the License.
10  
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  GNU General Public License for more details.
15  */
16
17 #ifndef __Object_h__
18 #define __Object_h__
19
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23         
24 /*  A "base object type" to implement reference counting
25     and management by unique names  */
26 typedef struct Object {
27         int    refCount;
28         struct Object *next;
29         const char *name;
30 } Object;
31
32 void ObjectInit(Object *obj, Object **objRootPtr, const char *name);
33 int ObjectIncrRefCount(Object *obj);
34 int ObjectDecrRefCount(Object *obj);
35 void ObjectDealloc(Object *obj, Object **objRootPtr);
36 void ObjectSetName(Object *obj, const char *name, Object *objRoot);
37 const char *ObjectGetName(Object *obj);
38 Object *ObjectWithName(const char *name, Object *objRoot);
39
40 #ifdef __cplusplus
41 }
42 #endif
43                 
44 #endif /* __Object_h__ */