Salome HOME
mergefrom branch BR_V511_PR tag mergeto_trunk_03feb09
[modules/yacs.git] / src / engine / Catalog.cxx
1 //  Copyright (C) 2006-2008  CEA/DEN, EDF R&D
2 //
3 //  This library is free software; you can redistribute it and/or
4 //  modify it under the terms of the GNU Lesser General Public
5 //  License as published by the Free Software Foundation; either
6 //  version 2.1 of the License.
7 //
8 //  This library is distributed in the hope that it will be useful,
9 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 //  Lesser General Public License for more details.
12 //
13 //  You should have received a copy of the GNU Lesser General Public
14 //  License along with this library; if not, write to the Free Software
15 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 #include "Catalog.hxx"
20 #include "ComponentDefinition.hxx"
21 #include "TypeCode.hxx"
22 #include "Node.hxx"
23 #include "ComposedNode.hxx"
24
25 //#define _DEVDEBUG_
26 #include "YacsTrace.hxx"
27
28 using namespace std;
29 using namespace YACS::ENGINE;
30
31 Catalog::Catalog(const std::string& name):_name(name)
32 {
33 }
34
35 Catalog::~Catalog()
36 {
37   DEBTRACE("Catalog::~Catalog");
38   //decref type codes in map
39   std::map<std::string, TypeCode *>::iterator pt;
40   for(pt=_typeMap.begin();pt!=_typeMap.end();pt++)
41     ((*pt).second)->decrRef();
42
43   //get rid of component definitions in  map
44   std::map<std::string, ComponentDefinition*>::const_iterator lt;
45   for(lt=_componentMap.begin();lt!=_componentMap.end();lt++)
46     delete (*lt).second;
47
48   //get rid of nodes in  map
49   std::map<std::string, Node*>::const_iterator nt;
50   for(nt=_nodeMap.begin();nt!=_nodeMap.end();nt++)
51     delete (*nt).second;
52
53   //get rid of composed nodes in  map
54   std::map<std::string, ComposedNode*>::const_iterator ct;
55   for(ct=_composednodeMap.begin();ct!=_composednodeMap.end();ct++)
56     delete (*ct).second;
57
58 }
59
60 CatalogLoader::CatalogLoader():_path("proto")
61 {
62 }
63
64 CatalogLoader::CatalogLoader(const std::string& path):_path(path)
65 {
66 }
67
68 CatalogLoader::~CatalogLoader()
69 {
70   DEBTRACE("CatalogLoader::~CatalogLoader");
71 }
72
73 void CatalogLoader::load(Catalog* cata,const std::string& path)
74 {
75   CatalogLoader* CL=newLoader(path);
76   CL->loadCata(cata);
77   delete CL;
78 }