Salome HOME
a7d5c70c7aba83e4fbd7e5e52038228f6baf0f3b
[modules/yacs.git] / src / engine / Catalog.cxx
1 // Copyright (C) 2006-2014  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, or (at your option) any later version.
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
20 #include "Catalog.hxx"
21 #include "ComponentDefinition.hxx"
22 #include "TypeCode.hxx"
23 #include "Node.hxx"
24 #include "ComposedNode.hxx"
25
26 //#define _DEVDEBUG_
27 #include "YacsTrace.hxx"
28
29 using namespace std;
30 using namespace YACS::ENGINE;
31
32 Catalog::Catalog(const std::string& name):_name(name)
33 {
34 }
35
36 Catalog::~Catalog()
37 {
38   DEBTRACE("Catalog::~Catalog");
39   //decref type codes in map
40   std::map<std::string, TypeCode *>::iterator pt;
41   for(pt=_typeMap.begin();pt!=_typeMap.end();pt++)
42     ((*pt).second)->decrRef();
43
44   //get rid of component definitions in  map
45   std::map<std::string, ComponentDefinition*>::const_iterator lt;
46   for(lt=_componentMap.begin();lt!=_componentMap.end();lt++)
47     delete (*lt).second;
48
49   //get rid of nodes in  map
50   std::map<std::string, Node*>::const_iterator nt;
51   for(nt=_nodeMap.begin();nt!=_nodeMap.end();nt++)
52     delete (*nt).second;
53
54   //get rid of composed nodes in  map
55   std::map<std::string, ComposedNode*>::const_iterator ct;
56   for(ct=_composednodeMap.begin();ct!=_composednodeMap.end();ct++)
57     delete (*ct).second;
58
59 }
60
61 CatalogLoader::CatalogLoader():_path("proto")
62 {
63 }
64
65 CatalogLoader::CatalogLoader(const std::string& path):_path(path)
66 {
67 }
68
69 CatalogLoader::~CatalogLoader()
70 {
71   DEBTRACE("CatalogLoader::~CatalogLoader");
72 }
73
74 void CatalogLoader::load(Catalog* cata,const std::string& path)
75 {
76   CatalogLoader* CL=newLoader(path);
77   CL->loadCata(cata);
78   delete CL;
79 }