00001 #ifndef X3DTK_SFTYPE_H 00002 #define X3DTK_SFTYPE_H 00003 00004 #include "X3DTypes.h" 00005 #include "SFSceneGraph.h" 00006 #include "SFComponent.h" 00007 00008 namespace X3DTK { 00009 00010 class Visitor; 00011 class BaseRecorder; 00012 00013 namespace X3D { 00014 class Creator; 00015 class X3DComponentCreator; 00016 } 00017 00028 class SFType 00029 { 00030 friend class X3D::Creator; 00031 friend class Walker; 00032 friend class Visitor; 00033 friend class BaseRecorder; 00034 friend class X3D::X3DComponentCreator; 00035 friend class X3DComponentWalker; 00036 friend class X3DComponentVisitor; 00037 friend class X3DAbstractNode; 00038 00039 public: 00041 static SFType *getTypeOfName(const SFString &sceneGraph, const SFString &component, const SFString &name); 00043 static SFType *getTypeOfId(int id); 00045 static void recomputeIds(); 00046 00048 inline SFString getName() const {return _name;}; 00050 inline SFString getComponentName() const {return _component->getName();}; 00052 inline SFString getSceneGraphName() const {return _component->getSceneGraph()->getName();}; 00054 inline int getId() const {return _id;}; 00056 inline SFType *getParent() const {return _parent;}; 00058 inline MFType getChildren() const {return _childList;}; 00060 inline SFComponent *getComponent() const {return _component;}; 00062 inline SFSceneGraph *getSceneGraph() const {return _component->getSceneGraph();}; 00064 static void printInheritanceTree(); 00065 00067 static SFString encodeKey(const SFString &sceneGraph, const SFString &component, const SFString &SFType); 00069 inline SFString getEncodedName() const {return encodeKey(getSceneGraphName(), getComponentName(), getName());}; 00070 00071 private: 00073 SFType(const SFString &name, const SFString &component, const SFString &sceneGraph); 00074 ~SFType(); 00075 00077 void setParent(SFType *parent); 00079 void addOneReference(); 00081 void addOneReferenceRecursive(); 00083 static void removeOneReference(SFType *type); 00084 00086 static void defineTypeName(SFType **type, const SFString &name, const SFString &component, const SFString &sceneGraph); 00088 static void addVisitor(Visitor *visitor); 00090 static void removeVisitor(Visitor *visitor); 00091 00094 static void beginFunctionDefinition(); 00096 static void endFunctionDefinition(); 00097 00099 SFString _name; 00100 int _id; 00101 int _refCount; 00102 SFType *_parent; 00103 MFType _childList; 00104 SFComponent *_component; 00105 00107 static int count; 00108 static MFType _typeList; 00109 static std::list<Visitor *> _actorList; 00110 static bool _functionDefinition; 00111 00112 void printInheritanceTree(SFString tab) const; 00113 }; 00114 00115 } 00116 00117 #endif