]> git.lyx.org Git - lyx.git/blob - sigc++/object.h
remove bogus define
[lyx.git] / sigc++ / object.h
1 // -*- c++ -*-
2 /* 
3  * Copyright 1999 Karl Nelson <kenelson@ece.ucdavis.edu>
4  * 
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  * 
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Library General Public License for more details.
14  * 
15  * You should have received a copy of the GNU Library General Public
16  * License along with this library; if not, write to the Free
17  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */
19 #ifndef SIGCXX_OBJECT_H
20 #define SIGCXX_OBJECT_H
21 #include <sigc++/sigc++config.h>
22 #include <sigc++/scope.h>
23
24
25 #ifdef SIGC_CXX_NAMESPACES
26 namespace SigC
27 {
28 #endif
29
30 extern int sigc_micro_version;
31 extern int sigc_minor_version;
32 extern int sigc_major_version;
33
34 class Invalid_;
35 class LIBSIGC_API ObjectReferenced
36   {
37    friend class Reference;
38    friend class Scope;
39    friend class Invalid_;
40
41 #ifdef SIGC_CXX_FRIEND_TEMPLATES
42    template <class T>
43      friend T* manage(T*);
44 #endif
45
46    protected:
47      // count of current references
48      unsigned int obj_count_    :24;
49
50      // indicates object generated through an interface that marks dynamic
51      unsigned int obj_dynamic_  :1;
52
53      // indicates the pointed to scope is the owner
54      unsigned int obj_owned_    :1;
55
56      // indicates object not will delete when count reachs zero
57      unsigned int obj_floating_ :1;
58
59      // indicates the owned scope is surrendering ownership
60      unsigned int obj_transfer_ :1;
61
62      // indicates the object is doing a list clean up 
63      unsigned int obj_invalid_  :1;
64
65      // indicates the object been destroyed 
66      unsigned int obj_destroyed_ :1;
67
68      // indicates there is a weak reference
69      unsigned int obj_weak_ :1;
70
71
72    /*************************************************************/
73 #ifdef SIGC_CXX_FRIEND_TEMPLATES
74    protected:
75 #else
76    public:
77 #endif
78      // For the controller and scope
79      virtual void set_dynamic(); 
80      inline void set_sink() {obj_floating_=0;}
81
82    protected:
83
84      inline void register_ref(Reference *)
85        {  
86         if (obj_transfer_) 
87          {
88           obj_transfer_=0;
89           obj_owned_=0;
90          }
91        }
92   
93    public:
94      virtual void reference();
95      virtual void unreference();
96
97      inline bool is_dynamic()  {return obj_dynamic_;}
98      inline bool is_floating() {return obj_floating_;}
99
100      ObjectReferenced();
101      virtual ~ObjectReferenced();
102   };
103
104
105 class LIBSIGC_API ObjectScoped :public ObjectReferenced
106   {
107    friend class Scope;
108    typedef ScopeList List_;
109
110    private:
111      mutable List_ list_;
112
113    // interface for scopes
114      void register_scope(Scope *scope,const Scope *parent=0);
115      void unregister_scope(Scope *scope);
116
117    protected:
118      // This sets a very weak reference which is removed at next invalid
119      void set_weak();
120
121    public:
122      void register_data(ScopeNode* data);
123
124      // inform connections that object wishs to delete
125      void invalid(bool destroy=0);
126
127      ObjectScoped();
128      virtual ~ObjectScoped();
129   };
130
131
132 // There can only be one Scope_Object per any object
133 class LIBSIGC_API Object: public virtual ObjectScoped 
134   {
135    public:
136      Object() {}
137      virtual ~Object();
138   };
139
140 // mark this a managable object
141 template <class T>
142 inline T* manage(T* t)
143   { 
144    if (t) t->set_dynamic();
145    return t;
146   }
147
148
149 #ifdef SIGC_CXX_NAMESPACES
150 } // namespace
151 #endif
152
153 #endif