Version: 9.15.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

◆ ProcCataLoader() [1/2]

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

Definition at line 38 of file ProcCataLoader.hxx.

38 :CatalogLoader(),_xmlLoader(xmlLoader){};
YACS::YACSLoader * _xmlLoader

Referenced by newLoader().

◆ ProcCataLoader() [2/2]

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::~ProcCataLoader ( )
virtual

Definition at line 42 of file ProcCataLoader.cxx.

43 {
44  DEBTRACE ("ProcCataLoader::~ProcCataLoader");
45 }
#define DEBTRACE(msg)
Definition: YacsTrace.hxx:31

References DEBTRACE.

Member Function Documentation

◆ loadCata()

void ProcCataLoader::loadCata ( Catalog cata)
virtual

Implements YACS::ENGINE::CatalogLoader.

Definition at line 47 of file ProcCataLoader.cxx.

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 }
std::list< Node * > getChildren() const
Definition: Bloc.hxx:57
void setErrors(const std::string &errors)
Definition: Catalog.hxx:48
std::map< std::string, ComposedNode * > _composednodeMap
Definition: Catalog.hxx:52
std::map< std::string, ComponentDefinition * > _componentMap
Definition: Catalog.hxx:50
std::map< std::string, Node * > _nodeMap
Definition: Catalog.hxx:51
std::map< std::string, TypeCode * > _typeMap
Definition: Catalog.hxx:49
Base class for all composed nodes.
std::string getName() const
Class for logging error messages.
Definition: Logger.hxx:38
virtual bool isEmpty()
Definition: Logger.cxx:96
virtual std::string getStr()
Definition: Logger.cxx:85
Node * clone(ComposedNode *father, bool editionOnly=true) const
This method MUST NEVER BE VIRTUAL
Definition: Node.cxx:131
Base class for all schema objects.
Definition: Proc.hxx:44
virtual Logger * getLogger(const std::string &name)
Definition: Proc.cxx:431
std::map< std::string, TypeCode * > typeMap
Definition: Proc.hxx:90
const char * what(void) const noexcept
Definition: Exception.cxx:50
virtual YACS::ENGINE::Proc * load(const char *filename)
Definition: parsers.cxx:63
Proc * p
Definition: driver.cxx:216

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().

◆ newLoader()

virtual CatalogLoader* YACS::ENGINE::ProcCataLoader::newLoader ( const std::string &  path)
inlinevirtual

Implements YACS::ENGINE::CatalogLoader.

Definition at line 42 of file ProcCataLoader.hxx.

42 {return new ProcCataLoader(_xmlLoader,path);}
ProcCataLoader(YACS::YACSLoader *xmlLoader)

References _xmlLoader, and ProcCataLoader().

Member Data Documentation

◆ _xmlLoader

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: