OSDN Git Service

FIRST REPOSITORY
[eos/hostdependOTHERS.git] / I386LINUX / util / I386LINUX / include / vtk / vtkObjectBase.h
1 /*=========================================================================
2
3   Program:   Visualization Toolkit
4   Module:    $RCSfile: vtkObjectBase.h,v $
5   Language:  C++
6   Date:      $Date: 2002/12/03 23:41:30 $
7   Version:   $Revision: 1.7 $
8
9   Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen 
10   All rights reserved.
11   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
12
13      This software is distributed WITHOUT ANY WARRANTY; without even 
14      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
15      PURPOSE.  See the above copyright notice for more information.
16
17 =========================================================================*/
18 // .NAME vtkObjectBase - abstract base class for most VTK objects
19 // .SECTION Description
20 // vtkObjectBase is the base class for all reference counted classes
21 // in the VTK. These classes include vtkCommand classes, vtkContainer
22 // classes, and vtkObject classes.
23 //
24 // vtkObjectBase performs reference counting: objects that are
25 // reference counted exist as long as another object uses them. Once
26 // the last reference to a reference counted object is removed, the
27 // object will spontaneously destruct.
28 // 
29 // Constructor and destructor of the subclasses of vtkObjectBase
30 // should be protected, so that only New() and UnRegister() actually
31 // call them. Debug leaks can be used to see if there are any objects
32 // left with nonzero reference count.
33 //
34 // .SECTION Caveats
35 // Note: Objects of subclasses of vtkObjectBase should always be
36 // created with the New() method and deleted with the Delete()
37 // method. They cannot be allocated off the stack (i.e., automatic
38 // objects) because the constructor is a protected method.
39 //
40 // .SECTION See also
41 // vtkObject vtkCommand vtkContainer
42
43 #ifndef __vtkObjectBase_h
44 #define __vtkObjectBase_h
45
46 #include "vtkIndent.h"
47 #include "vtkSystemIncludes.h"
48
49 class VTK_COMMON_EXPORT vtkObjectBase 
50 {
51 public:
52   // Description:
53   // Return the class name as a string. This method is defined
54   // in all subclasses of vtkObjectBase with the vtkTypeRevisionMacro found
55   // in vtkSetGet.h.
56   virtual const char *GetClassName() const {return "vtkObjectBase";};
57
58   // Description:
59   // Return 1 if this class type is the same type of (or a subclass of)
60   // the named class. Returns 0 otherwise. This method works in
61   // combination with vtkTypeRevisionMacro found in vtkSetGet.h.
62   static int IsTypeOf(const char *name);
63
64   // Description:
65   // Return 1 if this class is the same type of (or a subclass of)
66   // the named class. Returns 0 otherwise. This method works in
67   // combination with vtkTypeRevisionMacro found in vtkSetGet.h.
68   virtual int IsA(const char *name);
69
70   // Description:
71   // Delete a VTK object.  This method should always be used to delete
72   // an object when the New() method was used to create it. Using the
73   // C++ delete method will not work with reference counting.
74   virtual void Delete();
75
76   // Description:
77   // Create an object with Debug turned off, modified time initialized 
78   // to zero, and reference counting on.
79   static vtkObjectBase *New() 
80     {return new vtkObjectBase;}
81   
82 #ifdef _WIN32
83   // avoid dll boundary problems
84   void* operator new( size_t tSize );
85   void operator delete( void* p );
86 #endif 
87   
88   // Description:
89   // Print an object to an ostream. This is the method to call
90   // when you wish to see print the internal state of an object.
91   void Print(ostream& os);
92
93   // Description:
94   // Methods invoked by print to print information about the object
95   // including superclasses. Typically not called by the user (use
96   // Print() instead) but used in the hierarchical print process to
97   // combine the output of several classes.
98   virtual void PrintSelf(ostream& os, vtkIndent indent);
99   virtual void PrintHeader(ostream& os, vtkIndent indent);
100   virtual void PrintTrailer(ostream& os, vtkIndent indent);
101
102   // Description:
103   // Increase the reference count (mark as used by another object).
104   void Register(vtkObjectBase* o);
105
106   // Description:
107   // Decrease the reference count (release by another object). This
108   // has the same effect as invoking Delete() (i.e., it reduces the
109   // reference count by 1).
110   virtual void UnRegister(vtkObjectBase* o);
111
112   // Description:
113   // Return the current reference count of this object.
114   int  GetReferenceCount() 
115     {return this->ReferenceCount;}
116
117   // Description:
118   // Sets the reference count. (This is very dangerous, use with care.)
119   void SetReferenceCount(int);
120   
121   // Description:
122   // Prints a list of the class .cxx file CVS revisions for all
123   // classes in the object's inheritance chain.  The format of the
124   // list is "vtkObjectBase 1.4\n" with one class per line.  The list
125   // always starts with the least-derived class (vtkObjectBase), and
126   // ends with the most-derived class.  This is useful for programs
127   // wishing to do serialization of VTK objects.
128   void PrintRevisions(ostream& os);
129   
130 protected:
131   vtkObjectBase(); 
132   virtual ~vtkObjectBase(); 
133
134   virtual void CollectRevisions(ostream& os);
135   
136   int ReferenceCount;      // Number of uses of this object by other objects
137
138 private:
139   //BTX
140   friend VTK_COMMON_EXPORT ostream& operator<<(ostream& os, vtkObjectBase& o);
141   //ETX
142
143 protected:
144 //BTX
145   vtkObjectBase(const vtkObjectBase&) {}
146   void operator=(const vtkObjectBase&) {}
147 //ETX
148 };
149
150 #endif
151