FUtils/FUObject.h

Go to the documentation of this file.
00001 /*
00002     Copyright (C) 2005-2006 Feeling Software Inc.
00003     MIT License: http://www.opensource.org/licenses/mit-license.php
00004 */
00005 /*
00006     The idea is simple: the object registers itself in the constructor, with one container.
00007     It may register/unregister itself with other containers subsequently.
00008 
00009     It keeps a list of the containers and a pointer to the main container so that the up-classes
00010     can easily access it. In the destructor, the object unregisters itself with the container(s).
00011 
00012     The object has a RTTI-like static class structure so that the container(s) know which
00013     object type list to remove this object from when it is deleted.
00014 */
00015 
00021 #ifndef _FU_OBJECT_H_
00022 #define _FU_OBJECT_H_
00023 
00024 class FUObjectContainer;
00025 
00026 #include "FUtils/FUObjectType.h"
00027 
00035 class FCOLLADA_EXPORT FUObject
00036 {
00037 private:
00038     FUObjectContainer* container;
00039     static class FUObjectType* baseObjectType;
00040 
00041 protected:
00044     inline FUObjectContainer* GetContainer() { return container; }
00045     inline const FUObjectContainer* GetContainer() const { return container; } 
00047 public:
00053     FUObject(FUObjectContainer* container);
00054 
00057     ~FUObject();
00058 
00061     static const FUObjectType& GetClassType() { return *baseObjectType; }
00062 
00065     virtual const FUObjectType& GetObjectType() const { return *baseObjectType; }
00066 };
00067 
00069 typedef vector<FUObject*> FUObjectList;
00070 
00078 class FCOLLADA_EXPORT FUObjectContainer
00079 {
00080 private:
00081     friend class FUObject;
00082     FUObjectList objects;
00083 
00084     void RegisterObject(FUObject* object);
00085     void UnregisterObject(FUObject* object);
00086 
00087 public:
00089     FUObjectContainer() {}
00090 
00093     virtual ~FUObjectContainer();
00094 
00095 protected:
00099     inline const FUObjectList& GetObjects() const { return objects; }
00100 };
00101 
00102 #endif // _FU_OBJECT_H_

Generated on Fri May 12 16:44:39 2006 for FCollada by  doxygen 1.4.6-NO