Version: 8.3.0
YACS::ENGINE::ProcCataLoader Class Reference

#include <ProcCataLoader.hxx>

Inheritance diagram for YACS::ENGINE::ProcCataLoader:
Collaboration diagram for YACS::ENGINE::ProcCataLoader:

Public Member Functions

 ProcCataLoader (YACS::YACSLoader *xmlLoader)
 
 ProcCataLoader (YACS::YACSLoader *xmlLoader, const std::string &path)
 
virtual ~ProcCataLoader ()
 
virtual void loadCata (Catalog *cata)
 
virtual CatalogLoadernewLoader (const std::string &path)
 
- Public Member Functions inherited from YACS::ENGINE::CatalogLoader
 CatalogLoader ()
 
 CatalogLoader (const std::string &path)
 
virtual ~CatalogLoader ()
 
virtual void load (Catalog *cata, const std::string &path)
 

Protected Attributes

YACS::YACSLoader_xmlLoader
 
- Protected Attributes inherited from YACS::ENGINE::CatalogLoader
std::string _path
 

Detailed Description

Definition at line 35 of file ProcCataLoader.hxx.

Constructor & Destructor Documentation

YACS::ENGINE::ProcCataLoader::ProcCataLoader ( YACS::YACSLoader xmlLoader)
inline

Definition at line 38 of file ProcCataLoader.hxx.

Referenced by newLoader().

38 :CatalogLoader(),_xmlLoader(xmlLoader){};
ProcCataLoader::ProcCataLoader ( YACS::YACSLoader xmlLoader,
const std::string &  path 
)

Definition at line 37 of file ProcCataLoader.cxx.

37  :CatalogLoader(path),_xmlLoader(xmlLoader)
38 {
39  //path should be a file path
40 }
ProcCataLoader::~ProcCataLoader ( )
virtual

Definition at line 42 of file ProcCataLoader.cxx.

References DEBTRACE.

43 {
44  DEBTRACE ("ProcCataLoader::~ProcCataLoader");
45 }

Member Function Documentation

void ProcCataLoader::loadCata ( Catalog cata)
virtual

Implements YACS::ENGINE::CatalogLoader.

Definition at line 47 of file ProcCataLoader.cxx.

References YACS::ENGINE::Catalog::_componentMap, YACS::ENGINE::Catalog::_composednodeMap, YACS::ENGINE::Catalog::_nodeMap, YACS::ENGINE::CatalogLoader::_path, YACS::ENGINE::Catalog::_typeMap, _xmlLoader, YACS::ENGINE::Node::clone(), DEBTRACE, YACS::ENGINE::Bloc::getChildren(), YACS::ENGINE::Proc::getLogger(), YACS::ENGINE::ComposedNode::getName(), YACS::ENGINE::Logger::getStr(), YACS::ENGINE::Logger::isEmpty(), YACS::YACSLoader::load(), p, YACS::ENGINE::Catalog::setErrors(), YACS::ENGINE::Proc::typeMap, and YACS::Exception::what().

48 {
49  DEBTRACE("ProcCataLoader::load");
50  Proc* p;
51  try
52  {
53  p=_xmlLoader->load(_path.c_str());
54  if(p==0)
55  {
56  std::string msg="the file is probably not a YACS schema file";
57  cata->setErrors(msg);
58  std::cerr << msg << std::endl;
59  return;
60  }
61  }
62  catch (YACS::Exception& e)
63  {
64  std::string msg="Caught a YACS exception";
65  msg=msg + e.what();
66  std::cerr << msg << std::endl;
67  cata->setErrors(msg);
68  return ;
69  }
70  catch (const std::invalid_argument& e)
71  {
72  cata->setErrors(e.what());
73  return ;
74  }
75  catch (const std::ios_base::failure&)
76  {
77  std::string msg="Caught an io failure exception";
78  std::cerr << msg << std::endl;
79  cata->setErrors(msg);
80  return ;
81  }
82 
83  //Get the parser logger
84  Logger* logger=p->getLogger("parser");
85  //Print errors logged if any
86  if(!logger->isEmpty())
87  {
88  std::string msg=logger->getStr();
89  std::cerr << msg << std::endl;
90  cata->setErrors(msg);
91  }
92 
93  std::map<std::string,TypeCode*>& typeMap=cata->_typeMap;
94  std::map<std::string,Node*>& nodeMap=cata->_nodeMap;
95  std::map<std::string,ComposedNode*>& composednodeMap=cata->_composednodeMap;
96  std::map<std::string,ComponentDefinition*>& componentMap=cata->_componentMap;
97 
98  std::map<std::string,TypeCode*>::iterator it=p->typeMap.begin();
99  while(it != p->typeMap.end())
100  {
101  typeMap[it->first]=it->second;
102  it->second->incrRef();
103  it++;
104  }
105 
106  std::list<Node *> s=p->getChildren();
107  for(std::list<Node *>::iterator iter=s.begin();iter!=s.end();iter++)
108  {
109  YACS::ENGINE::ComposedNode * cnode= dynamic_cast<YACS::ENGINE::ComposedNode *>(*iter);
110  if(cnode)
111  composednodeMap[cnode->getName()]=(YACS::ENGINE::ComposedNode *) cnode->clone(0);
112  else
113  nodeMap[(*iter)->getName()]=(*iter)->clone(0);
114  }
115  delete p;
116 }
virtual CatalogLoader* YACS::ENGINE::ProcCataLoader::newLoader ( const std::string &  path)
inlinevirtual

Implements YACS::ENGINE::CatalogLoader.

Definition at line 42 of file ProcCataLoader.hxx.

References _xmlLoader, and ProcCataLoader().

42 {return new ProcCataLoader(_xmlLoader,path);}

Member Data Documentation

YACS::YACSLoader* YACS::ENGINE::ProcCataLoader::_xmlLoader
protected

Definition at line 44 of file ProcCataLoader.hxx.

Referenced by loadCata(), and newLoader().


The documentation for this class was generated from the following files: