X3DAbstractNode.h

Go to the documentation of this file.
00001 #ifndef X3DTK_X3DABSTRACTNODE_H
00002 #define X3DTK_X3DABSTRACTNODE_H
00003 
00004 #include "X3DTypes.h"
00005 #include "X3DFileElement.h"
00006 #include "SFType.h"
00007 #include "Recorder.h"
00008 
00009 namespace X3DTK {
00010 
00011 class FileElement;
00012 
00021 class X3DAbstractNode
00022 {
00023 public:
00025   X3DAbstractNode();
00027   SFNode clone() const;
00029   virtual ~X3DAbstractNode();
00030   
00032   void setName(const SFString &name);
00033 
00035   inline const SFString &getName() const {return _name;};
00037   inline const SFString &getTypeName() const {return _type->getName();};
00039   inline const SFString &getSceneGraphName() const {return _type->getSceneGraphName();};
00041   inline SFType *getType() const {return _type;};
00043   MFNode getChildList();
00045   inline MFNode getParentList() const {return _parentList;};
00046     
00049   bool setChild(SFNode N);
00051   bool removeChild(SFNode N);
00052 
00054   X3DField get(const SFString &name) const; 
00056   void set(const SFString &name, const X3DField &field); 
00058   void loadAttribute(const SFString &name, const SFString &value);
00060   SFString writeAttribute(const SFString &name);
00062   void loadAttributes(const X3DFileElement *element);
00064   void writeAttributes(SFString &output);
00066   static void addParentToChild(SFNode parent, SFNode child);
00068   static void removeParentFromChild(SFNode parent, SFNode child);
00069   
00070 protected:
00072   inline void define(const TypeName &typeName) {SFType::defineTypeName(&_type, typeName.name, typeName.component, typeName.sceneGraph, typeName.cloner);};  
00074   inline void define(const X3DAttributeRecorder &recorder) {recorder.record(this);};
00076   inline void define(const X3DSFNodeRecorder &recorder) {recorder.record(this);};
00078   inline void define(const X3DMFNodeRecorder &recorder) {recorder.record(this);};
00079 
00080 #ifdef TEMPLATE_SPECIALIZATION_SUPPORTED
00084   inline void defineTypeName(const SFString &name, const SFString &component = SFString(""), const SFString &sceneGraph = SFString("")) {defineTempTypeName(this, name, component, sceneGraph);};
00085 
00086   template<class T>
00087   inline void defineTempTypeName(T *t, const SFString &name, const SFString &component, const SFString &sceneGraph) {define(Recorder<T>::getTypeName(name, component, sceneGraph));};
00089   template<class T, class V>
00090   inline void defineAttribute(const SFString &name, V T:: *member, const V &init);
00092   template<class T, class V>
00093   inline void defineNode(const SFString &name, V T:: *node);
00095   template<class T, class V>
00096   inline void defineNodes(const SFString &name, MFNode T:: *nodes);
00097 #endif
00098   
00100   void removeChildren();
00101   
00102 private:   
00104   X3DAbstractNode(const X3DAbstractNode &N);
00106   inline void addOneReference() const {_type->addOneReferenceRecursive();};
00107 
00108   SFString _name;
00109   SFType *_type;
00110   MFNode _parentList;
00111   
00113   void addParent(const SFNode &N);
00115   bool removeParent(const SFNode &N);
00116 };
00117 
00118 }
00119 
00120 #include "X3DAbstractNode.inl"
00121 
00122 #endif

Generated on Fri Jul 30 12:02:29 2004 for X3DToolKit by doxygen 1.3.6