#include "SFSceneGraph.h" #include "SFComponent.h" #include #include using namespace std; using namespace X3DTK; MFSceneGraph SFSceneGraph::_sceneGraphList = MFSceneGraph(); SFSceneGraph::SFSceneGraph(const SFString &name) : _name(name), _refCount(0), _componentList(MFComponent()) { //cout << "build SFSceneGraph " << name << ": " << this << endl; _sceneGraphList[name] = this; } SFSceneGraph::~SFSceneGraph() { //cout << "destr SFSceneGraph " << _name << endl; } SFSceneGraph *SFSceneGraph::getSceneGraph(const SFString &name) { MFSceneGraph::const_iterator it = _sceneGraphList.find(name); if (it != _sceneGraphList.end()) return (*it).second; //the SFType doesn't exist. return 0; } void SFSceneGraph::addOneReference() { ++_refCount; //cout << "add ref SFSceneGraph " << _name << " = " << _refCount << endl; } void SFSceneGraph::removeOneReference(SFSceneGraph *sceneGraph) { --sceneGraph->_refCount; //cout << "remove ref SFSceneGraph " << SFSceneGraph->getName() << " = " << SFSceneGraph->_refCount << endl; if (sceneGraph->_refCount == 0) { // delete SFSceneGraph _sceneGraphList.erase(sceneGraph->_name); delete sceneGraph; } } void SFSceneGraph::addComponent(SFComponent *component) { _componentList[component->getName()] = component; }