Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

X3DAbstractNode.cpp

Go to the documentation of this file.
00001 #include "X3DAbstractNode.h"
00002 #include "Type.h"
00003 #include "Scene.h"
00004 
00005 #include <iostream>
00006 
00007 using namespace X3DTK;
00008 using namespace std;
00009 
00010 NameDict X3DAbstractNode::DEFDict = NameDict();
00011 
00012 X3DAbstractNode::X3DAbstractNode()
00013 : _type(0)
00014 {    
00015   defineTagName("X3DAbstractNode", "Root");
00016 }
00017 
00018 SFNode X3DAbstractNode::clone() const
00019 {
00020   // Returns 0 because it is an abstract node.
00021   return 0;
00022 }
00023 
00024 X3DAbstractNode::X3DAbstractNode(const X3DAbstractNode &N)
00025 : _sceneList(N._sceneList), _type(N._type), _parentList(N._parentList)
00026 {
00027   defineTagName("X3DAbstractNode", "Root");
00028 }
00029 
00030 X3DAbstractNode::~X3DAbstractNode()
00031 {
00032   //this method is recursive and removes one instance for all the parents of
00033   //the type.
00034   Type::removeOneReference(_type);
00035   X3DAbstractNode::DEFDict.remove(this);
00037   for (MFNode::iterator it = _parentList.begin(); it != _parentList.end(); ++it)
00038     (*it)->removeChild(this);
00039 }
00040 
00041 void X3DAbstractNode::addParent(const SFNode &N)
00042 {
00043   if (N != 0)
00044     _parentList.push_back(N);
00045 }
00046 
00047 bool X3DAbstractNode::removeParent(const SFNode &N)
00048 {
00049   if (N != 0)
00050   {
00051     MFNode::iterator res = find(_parentList.begin(), _parentList.end(), N);
00052     if (res != _parentList.end())
00053     {
00054       _parentList.erase(res);
00055       return true;
00056     }
00057   }
00058   return false;
00059 }
00060 
00061 void X3DAbstractNode::loadAttributes(const X3DFileElement *element)
00062 {
00063 }
00064 
00065 SFString X3DAbstractNode::writeAttributes() const
00066 {
00067   return "";
00068 }
00069 
00070 bool X3DAbstractNode::addChild(const SFNode &N)
00071 {
00072   return false;
00073 }
00074 
00075 bool X3DAbstractNode::setChild(const SFNode &N)
00076 {
00077   return false;
00078 }
00079 
00080 bool X3DAbstractNode::removeChild(const SFNode &N)
00081 {
00082   return false;
00083 }
00084 
00085 void X3DAbstractNode::removeScenes(SFNode child, const MFScene &sceneList)
00086 {
00087   //union of the sets.
00088   if ((child != 0) && (sceneList.size() != 0))
00089   {
00090     for (MFScene::iterator it = sceneList.begin(); it != sceneList.end(); ++it)
00091       child->_sceneList.erase(*it);
00092       
00093     child->removeScenesToChildren(sceneList);
00094   }  
00095 }
00096 
00097 void X3DAbstractNode::removeScenesToChildren(const MFScene &sceneList)
00098 {
00099 }
00100 
00101 void X3DAbstractNode::addScenes(SFNode child, const MFScene &sceneList)
00102 {
00103   //union of the sets.
00104   if ((child != 0) && (sceneList.size() != 0))
00105   {
00106     child->_sceneList.insert<MFScene::iterator>(sceneList.begin(), sceneList.end());
00107     child->addScenesToChildren(sceneList);
00108   }  
00109 }
00110 
00111 void X3DAbstractNode::addScenesToChildren(const MFScene &sceneList)
00112 {
00113 }
00114 
00115 void X3DAbstractNode::removeLink(SFNode father, SFNode child)
00116 {
00117   if (child != 0)
00118   {
00119     child->removeParent(father);
00120     removeScenes(child, father->_sceneList);
00121   }  
00122 }
00123 
00124 void X3DAbstractNode::addLink(SFNode father, SFNode child)
00125 {
00126   if (child != 0)
00127   {
00128     child->addParent(father);
00129     addScenes(child, father->_sceneList);
00130   }  
00131 }

Generated on Wed May 14 10:03:11 2003 for X3DToolKit by doxygen1.3