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

Component.cpp

Go to the documentation of this file.
00001 #include "Component.h"
00002 #include "Type.h"
00003 
00004 #include <iostream>
00005 
00006 using namespace std;
00007 using namespace X3DTK;
00008 
00009 MFComponent Component::_componentList = MFComponent();
00010 
00011 Component::Component(const SFString &name)
00012 : _name(name), _refCount(0), _typeList(MFType())
00013 {
00014   //cout << "new Component " << name << endl;
00015   _componentList[name] = this;
00016 }
00017 
00018 Component::~Component()
00019 {
00020   //cout << "delete Component " << _name << endl;
00021 }
00022 
00023 Component *Component::getComponent(const SFString &name)
00024 {
00025   MFComponent::const_iterator it = _componentList.find(name); 
00026   if (it != _componentList.end())
00027     return (*it).second;
00028     
00029   //the type doesn't exist.
00030   return 0;  
00031 }
00032 
00033 void Component::addOneReference()
00034 {
00035   ++_refCount;
00036   //cout << "add ref Component " << _name << " = " << _refCount << endl;
00037 }
00038 
00039 void Component::removeOneReference(Component *component)
00040 {
00041   --component->_refCount;
00042   //cout << "remove ref Component " << component->getName() << " = " << component->_refCount << endl;
00043   
00044   if (component->_refCount == 0)
00045   {
00046     // delete component
00047     _componentList.erase(component->_name);
00048     delete component;
00049   }
00050 }
00051 
00052 
00053 void Component::addType(Type *type)
00054 {
00055   _typeList[type->getName()] = type;
00056 }

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