From 0ea5fc66924303d1bf73ba283a383e2aadee02f2 Mon Sep 17 00:00:00 2001 From: neodarz Date: Sat, 11 Aug 2018 20:21:34 +0200 Subject: Initial commit --- docs/doxygen/nel/a02756.html | 1247 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1247 insertions(+) create mode 100644 docs/doxygen/nel/a02756.html (limited to 'docs/doxygen/nel/a02756.html') diff --git a/docs/doxygen/nel/a02756.html b/docs/doxygen/nel/a02756.html new file mode 100644 index 00000000..0579e3ce --- /dev/null +++ b/docs/doxygen/nel/a02756.html @@ -0,0 +1,1247 @@ + + +NeL: NLLIGO::CLigoConfig class Reference + + + +
+

NLLIGO::CLigoConfig Class Reference

#include <ligo_config.h> +

+


Detailed Description

+Ligo config file

+

Author:
Cyril 'Hulud' Corvazier

+Nevrax France

+
Date:
2001
+ +

+ +

+Definition at line 47 of file ligo_config.h. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Primitive class accessors

bool canBeChild (const NLLIGO::IPrimitive &child, const NLLIGO::IPrimitive &parent)
bool canBeRoot (const NLLIGO::IPrimitive &primitive)
virtual void errorMessage (const char *format,...)
const std::vector< std::string > & getContextString () const
const CPrimitiveClassgetPrimitiveClass (const char *className) const
const CPrimitiveClassgetPrimitiveClass (const NLLIGO::IPrimitive &primitive) const
NLMISC::CRGBA getPrimitiveColor (const NLLIGO::IPrimitive &primitive)
const std::vector< CPrimitiveConfigurations > & getPrimitiveConfiguration () const
bool getPropertyString (std::string &result, const char *filename, xmlNodePtr xmlNode, const char *propName)
bool isPrimitiveDeletable (const NLLIGO::IPrimitive &primitive)
bool isPrimitiveLinked (const NLLIGO::IPrimitive &primitive)
void syntaxError (const char *filename, xmlNodePtr xmlNode, const char *format,...)
bool initPrimitiveClass (const char *filename)
std::map< std::string, std::string > _ContextFilesLookup
std::vector< std::string > _Contexts
std::map< std::string, CPrimitiveClass_PrimitiveClasses
std::vector< CPrimitiveConfigurations_PrimitiveConfigurations

Public Member Functions

bool read (const char *fileName)
bool readPrimitiveClass (const char *fileName)
virtual ~CLigoConfig ()

Data Fields

Public value
float CellSize
 Size of a cell of the ligoscape in meter.

std::string PrimitiveClassFilename
 The ligo class file.

float Snap
 Snap precision for vertex position checking in meter.

uint ZoneSnapShotRes
 Zone snap shot resolution.

+


Constructor & Destructor Documentation

+

+ + + + +
+ + + + + + + + + +
virtual NLLIGO::CLigoConfig::~CLigoConfig  )  [inline, virtual]
+
+ + + + + +
+   + + +

+ +

+Definition at line 51 of file ligo_config.h. +

+

00051 { }
+
+


Member Function Documentation

+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
bool NLLIGO::CLigoConfig::canBeChild const NLLIGO::IPrimitive child,
const NLLIGO::IPrimitive parent
+
+ + + + + +
+   + + +

+ +

+Definition at line 242 of file ligo_config.cpp. +

+References NLLIGO::CPrimitiveClass::DynamicChildren, NLLIGO::CPrimitiveClass::GeneratedChildren, NLLIGO::IPrimitive::getParent(), getPrimitiveClass(), NLLIGO::IPrimitive::getPropertyByName(), and uint. +

+

00243 {
+00244         // Get the child class
+00245         string childClassName;
+00246         if (child.getPropertyByName ("class", childClassName))
+00247         {
+00248                 // Get the parent class
+00249                 const CPrimitiveClass *parentClass = getPrimitiveClass (parent);
+00250                 if (parentClass)
+00251                 {
+00252                         // Search for the child class
+00253                         uint i;
+00254                         for (i=0; i<parentClass->DynamicChildren.size (); i++)
+00255                         {
+00256                                 // The same ?
+00257                                 if (parentClass->DynamicChildren[i].ClassName == childClassName)
+00258                                         break;
+00259                         }
+00260 
+00261                         if (i<parentClass->DynamicChildren.size ())
+00262                                 return true;
+00263 
+00264                         for (i=0; i<parentClass->GeneratedChildren.size (); i++)
+00265                         {
+00266                                 // The same ?
+00267                                 if (parentClass->GeneratedChildren[i].ClassName == childClassName)
+00268                                         break;
+00269                         }
+00270 
+00271                         return (i<parentClass->GeneratedChildren.size ());
+00272                 }
+00273                 else
+00274                         return true;
+00275         }
+00276         else
+00277         {
+00278                 // Only if it is a root node or parent class doesn't exist
+00279                 string parentClassName;
+00280                 return ( (parent.getParent () == NULL) || (!parent.getPropertyByName ("class", parentClassName) ) );
+00281         }       
+00282 }
+
+

+ + + + +
+ + + + + + + + + + +
bool NLLIGO::CLigoConfig::canBeRoot const NLLIGO::IPrimitive primitive  ) 
+
+ + + + + +
+   + + +

+ +

+Definition at line 286 of file ligo_config.cpp. +

+References NLLIGO::CPrimitiveClass::DynamicChildren, getPrimitiveClass(), NLLIGO::IPrimitive::getPropertyByName(), and uint. +

+

00287 {
+00288         // Get the child class
+00289         string childClassName;
+00290         if (child.getPropertyByName ("class", childClassName))
+00291         {
+00292                 // Get the parent class
+00293                 const CPrimitiveClass *parentClass = getPrimitiveClass ("root");
+00294                 if (parentClass)
+00295                 {
+00296                         // Search for the child class
+00297                         uint i;
+00298                         for (i=0; i<parentClass->DynamicChildren.size (); i++)
+00299                         {
+00300                                 // The same ?
+00301                                 if (parentClass->DynamicChildren[i].ClassName == childClassName)
+00302                                         break;
+00303                         }
+00304 
+00305                         return (i<parentClass->DynamicChildren.size ());
+00306                 }
+00307                 else
+00308                         return true;
+00309         }
+00310         else
+00311         {
+00312                 // Root class doesn't exist
+00313                 return ( !getPrimitiveClass ("root") );
+00314         }       
+00315 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
void NLLIGO::CLigoConfig::errorMessage const char *  format,
... 
[virtual]
+
+ + + + + +
+   + + +

+ +

+Definition at line 346 of file ligo_config.cpp. +

+References buffer, format, and nlwarning. +

+Referenced by readPrimitiveClass(), and syntaxError(). +

+

00347 {
+00348         // Make a buffer string
+00349         va_list args;
+00350         va_start( args, format );
+00351         char buffer[1024];
+00352         vsnprintf( buffer, 1024, format, args );
+00353         va_end( args );
+00354 
+00355         nlwarning (buffer);
+00356 }
+
+

+ + + + +
+ + + + + + + + + +
const std::vector< std::string > & NLLIGO::CLigoConfig::getContextString  )  const
+
+ + + + + +
+   + + +

+ +

+Definition at line 360 of file ligo_config.cpp. +

+References _Contexts. +

+

00361 {
+00362         return _Contexts;
+00363 }
+
+

+ + + + +
+ + + + + + + + + + +
const CPrimitiveClass * NLLIGO::CLigoConfig::getPrimitiveClass const char *  className  )  const
+
+ + + + + +
+   + + +

+ +

+Definition at line 400 of file ligo_config.cpp. +

+References _PrimitiveClasses. +

+

00401 {
+00402         std::map<std::string, CPrimitiveClass>::const_iterator ite = _PrimitiveClasses.find (className);
+00403         if (ite != _PrimitiveClasses.end ())
+00404         {
+00405                 return &(ite->second);
+00406         }
+00407         return NULL;
+00408 }
+
+

+ + + + +
+ + + + + + + + + + +
const CPrimitiveClass * NLLIGO::CLigoConfig::getPrimitiveClass const NLLIGO::IPrimitive primitive  )  const
+
+ + + + + +
+   + + +

+ +

+Definition at line 367 of file ligo_config.cpp. +

+References _PrimitiveClasses, NLLIGO::IPrimitive::getParent(), and NLLIGO::IPrimitive::getPropertyByName(). +

+Referenced by canBeChild(), canBeRoot(), and NLLIGO::IPrimitive::read(). +

+

00368 {
+00369         const CPrimitiveClass *primClass = NULL;
+00370 
+00371         // Get property class
+00372         string className;
+00373         if (primitive.getPropertyByName ("class", className))
+00374         {
+00375                 std::map<std::string, CPrimitiveClass>::const_iterator ite = _PrimitiveClasses.find (className);
+00376                 if (ite != _PrimitiveClasses.end ())
+00377                 {
+00378                         primClass = &(ite->second);
+00379                 }
+00380         }
+00381 
+00382         // Not found ?
+00383         if (!primClass)
+00384         {
+00385                 // Root ?
+00386                 if (!primitive.getParent ())
+00387                 {
+00388                         std::map<std::string, CPrimitiveClass>::const_iterator ite = _PrimitiveClasses.find ("root");
+00389                         if (ite != _PrimitiveClasses.end ())
+00390                         {
+00391                                 primClass = &(ite->second);
+00392                         }
+00393                 }
+00394         }
+00395         return primClass;
+00396 }
+
+

+ + + + +
+ + + + + + + + + + +
NLMISC::CRGBA NLLIGO::CLigoConfig::getPrimitiveColor const NLLIGO::IPrimitive primitive  ) 
+
+ + + + + +
+   + + +

+ +

+Definition at line 188 of file ligo_config.cpp. +

+References _PrimitiveClasses, DEFAULT_PRIMITIVE_COLOR, and NLLIGO::IPrimitive::getPropertyByName(). +

+

00189 {
+00190         // Get the class
+00191         string className;
+00192         if (primitive.getPropertyByName ("class", className))
+00193         {
+00194                 // Get the class
+00195                 std::map<std::string, CPrimitiveClass>::iterator ite = _PrimitiveClasses.find (className);
+00196                 if (ite != _PrimitiveClasses.end ())
+00197                 {
+00198                         return ite->second.Color;
+00199                 }
+00200         }
+00201         return DEFAULT_PRIMITIVE_COLOR;
+00202 }
+
+

+ + + + +
+ + + + + + + + + +
const std::vector<CPrimitiveConfigurations>& NLLIGO::CLigoConfig::getPrimitiveConfiguration  )  const [inline]
+
+ + + + + +
+   + + +

+ +

+Definition at line 114 of file ligo_config.h. +

+References _PrimitiveConfigurations. +

+

00115         {
+00116                 return _PrimitiveConfigurations;
+00117         }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
bool NLLIGO::CLigoConfig::getPropertyString std::string &  result,
const char *  filename,
xmlNodePtr  xmlNode,
const char *  propName
+
+ + + + + +
+   + + +

+ +

+Definition at line 319 of file ligo_config.cpp. +

+References syntaxError(). +

+Referenced by NLLIGO::CPrimitiveConfigurations::read(), NLLIGO::CPrimitiveClass::read(), and readPrimitiveClass(). +

+

00320 {
+00321         // Call the CIXml version
+00322         if (!CIXml::getPropertyString (result, xmlNode, propName))
+00323         {
+00324                 // Output a formated error
+00325                 syntaxError (filename, xmlNode, "Missing XML node property (%s)", propName);
+00326                 return false;
+00327         }
+00328         return true;
+00329 }
+
+

+ + + + +
+ + + + + + + + + + +
bool NLLIGO::CLigoConfig::initPrimitiveClass const char *  filename  )  [private]
+
+ + + + + +
+   + + +

+

+

+ + + + +
+ + + + + + + + + + +
bool NLLIGO::CLigoConfig::isPrimitiveDeletable const NLLIGO::IPrimitive primitive  ) 
+
+ + + + + +
+   + + +

+ +

+Definition at line 224 of file ligo_config.cpp. +

+References _PrimitiveClasses, and NLLIGO::IPrimitive::getPropertyByName(). +

+

00225 {
+00226         // Get the class
+00227         string className;
+00228         if (primitive.getPropertyByName ("class", className))
+00229         {
+00230                 // Get the class
+00231                 std::map<std::string, CPrimitiveClass>::iterator ite = _PrimitiveClasses.find (className);
+00232                 if (ite != _PrimitiveClasses.end ())
+00233                 {
+00234                         return ite->second.Deletable;
+00235                 }
+00236         }
+00237         return false;
+00238 }
+
+

+ + + + +
+ + + + + + + + + + +
bool NLLIGO::CLigoConfig::isPrimitiveLinked const NLLIGO::IPrimitive primitive  ) 
+
+ + + + + +
+   + + +

+ +

+Definition at line 206 of file ligo_config.cpp. +

+References _PrimitiveClasses, and NLLIGO::IPrimitive::getPropertyByName(). +

+

00207 {
+00208         // Get the class
+00209         string className;
+00210         if (primitive.getPropertyByName ("class", className))
+00211         {
+00212                 // Get the class
+00213                 std::map<std::string, CPrimitiveClass>::iterator ite = _PrimitiveClasses.find (className);
+00214                 if (ite != _PrimitiveClasses.end ())
+00215                 {
+00216                         return ite->second.LinkBrothers;
+00217                 }
+00218         }
+00219         return false;
+00220 }
+
+

+ + + + +
+ + + + + + + + + + +
bool NLLIGO::CLigoConfig::read const char *  fileName  ) 
+
+ + + + + +
+   + + +

+Load the config file. Can throw some exception if file doesn't exist or is malformed.

+This file will try to open the file ligo class description file (XML) using the LigoClass as file name. It will try first to load directly the file and then to lookup the file in NLMISC::CPath. +

+Definition at line 42 of file ligo_config.cpp. +

+References _Contexts, _PrimitiveClasses, _PrimitiveConfigurations, NLMISC::CConfigFile::CVar::asFloat(), NLMISC::CConfigFile::CVar::asInt(), NLMISC::CConfigFile::CVar::asString(), NLMISC::CConfigFile::getVar(), NLMISC::CConfigFile::load(), PrimitiveClassFilename, readPrimitiveClass(), Snap, uint, and ZoneSnapShotRes. +

+

00043 {
+00044         // The CF
+00045         CConfigFile cf;
+00046 
+00047         // Load and parse the file
+00048         cf.load (fileName);
+00049 
+00050         // Read the parameters
+00051         CConfigFile::CVar &cell_size = cf.getVar ("cell_size");
+00052         CellSize = cell_size.asFloat ();
+00053         CConfigFile::CVar &snap = cf.getVar ("snap");
+00054         Snap = snap.asFloat ();
+00055         CConfigFile::CVar &snapShot = cf.getVar ("zone_snapeshot_res");
+00056         ZoneSnapShotRes = (uint)snapShot.asInt ();
+00057         CConfigFile::CVar &primitiveClassFilename = cf.getVar ("primitive_class_filename");
+00058         PrimitiveClassFilename= primitiveClassFilename.asString ();
+00059         
+00060         // Clear the previous classes
+00061         _Contexts.clear();
+00062         _PrimitiveClasses.clear();
+00063         _PrimitiveConfigurations.clear();
+00064 
+00065         // Read the primitive class name
+00066         if (!PrimitiveClassFilename.empty())
+00067         {
+00068                 return readPrimitiveClass (PrimitiveClassFilename.c_str());
+00069         }
+00070         return true;
+00071 }
+
+

+ + + + +
+ + + + + + + + + + +
bool NLLIGO::CLigoConfig::readPrimitiveClass const char *  fileName  ) 
+
+ + + + + +
+   + + +

+This file will read the file ligo class description file (XML) using the LigoClass as file name. It will try first to load directly the file and then to lookup the file in NLMISC::CPath. +

+Definition at line 75 of file ligo_config.cpp. +

+References _ContextFilesLookup, _Contexts, _PrimitiveClasses, _PrimitiveConfigurations, errorMessage(), file, getPropertyString(), nlassert, and syntaxError(). +

+Referenced by read(). +

+

00076 {
+00077         // File exist ?
+00078         string filename = _fileName;
+00079         filename = CPath::lookup (_fileName, false, false, false);
+00080         if (filename.empty())
+00081                 filename = _fileName;
+00082 
+00083         // The context strings
+00084         set<string> contextStrings;
+00085 
+00086         // Read the document
+00087         CIFile file;
+00088         if (file.open (filename))
+00089         {
+00090                 try
+00091                 {
+00092                         // XML stream
+00093                         CIXml xml;
+00094                         xml.init (file);
+00095 
+00096                         // Get the root node
+00097                         xmlNodePtr root = xml.getRootNode ();
+00098                         nlassert (root);
+00099                         
+00100                         // Check the header
+00101                         if (strcmp ((const char*)root->name, "NEL_LIGO_PRIMITIVE_CLASS") == 0)
+00102                         {
+00103                                 // Get the first primitive description
+00104                                 xmlNodePtr primitive = CIXml::getFirstChildNode (root, "PRIMITIVE");
+00105                                 if (primitive)
+00106                                 {
+00107                                         do
+00108                                         {
+00109                                                 // Get the primitive name
+00110                                                 std::string name;
+00111                                                 if (getPropertyString (name, filename.c_str(), primitive, "CLASS_NAME"))
+00112                                                 {
+00113                                                         // Add the primitive
+00114                                                         pair<std::map<std::string, CPrimitiveClass>::iterator, bool> insertResult = 
+00115                                                                 _PrimitiveClasses.insert (std::map<std::string, CPrimitiveClass>::value_type (name, CPrimitiveClass ()));
+00116                                                         if (insertResult.second)
+00117                                                         {
+00118                                                                 if (!insertResult.first->second.read (primitive, filename.c_str(), name.c_str (), contextStrings, _ContextFilesLookup, *this))
+00119                                                                         return false;
+00120                                                         }
+00121                                                         else
+00122                                                         {
+00123                                                                 syntaxError (filename.c_str(), root, "Class (%s) aready defined", name.c_str ());
+00124                                                         }
+00125                                                 }
+00126                                                 else
+00127                                                         return false;
+00128                                         }
+00129                                         while ((primitive = CIXml::getNextChildNode (primitive, "PRIMITIVE")));
+00130                                 }
+00131                                         
+00132                                 // Add the context strings
+00133                                 {
+00134                                         set<string>::iterator ite = contextStrings.begin ();
+00135                                         while (ite != contextStrings.end ())
+00136                                         {
+00137                                                 if (*ite != "default")
+00138                                                         _Contexts.push_back (*ite);
+00139                                                 ite++;
+00140                                         }
+00141                                         _Contexts.push_back ("default");
+00142                                 }
+00143 
+00144                                 // Get the first primitive configuration
+00145                                 _PrimitiveConfigurations.reserve (CIXml::countChildren (root, "CONFIGURATION"));
+00146                                 xmlNodePtr configuration = CIXml::getFirstChildNode (root, "CONFIGURATION");
+00147                                 if (configuration)
+00148                                 {
+00149                                         do
+00150                                         {
+00151                                                 // Get the configuration name
+00152                                                 std::string name;
+00153                                                 if (getPropertyString (name, filename.c_str(), configuration, "NAME"))
+00154                                                 {
+00155                                                         // Add the configuration
+00156                                                         _PrimitiveConfigurations.resize (_PrimitiveConfigurations.size()+1);
+00157                                                         if (!_PrimitiveConfigurations.back().read (configuration, filename.c_str(), name.c_str (), *this))
+00158                                                                 return false;
+00159                                                 }
+00160                                                 else
+00161                                                         return false;
+00162                                         }
+00163                                         while ((configuration = CIXml::getNextChildNode (configuration, "CONFIGURATION")));
+00164                                 }
+00165 
+00166                                 // Ok
+00167                                 return true;
+00168                         }
+00169                         else
+00170                         {
+00171                                 syntaxError (filename.c_str(), root, "Wrong root node, should be NEL_LIGO_PRIMITIVE_CLASS");
+00172                         }
+00173                 }
+00174                 catch (Exception &e)
+00175                 {
+00176                         errorMessage ("File read error (%s):%s", filename.c_str(), e.what ());
+00177                 }
+00178         }
+00179         else
+00180         {
+00181                 errorMessage ("Can't open the file %s for reading.", filename.c_str());
+00182         }
+00183         return false;
+00184 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void NLLIGO::CLigoConfig::syntaxError const char *  filename,
xmlNodePtr  xmlNode,
const char *  format,
... 
+
+ + + + + +
+   + + +

+ +

+Definition at line 333 of file ligo_config.cpp. +

+References buffer, errorMessage(), and format. +

+Referenced by getPropertyString(), NLLIGO::CPrimitiveConfigurations::read(), NLLIGO::CPrimitiveClass::read(), and readPrimitiveClass(). +

+

00334 {
+00335         va_list args;
+00336         va_start( args, format );
+00337         char buffer[1024];
+00338         vsnprintf( buffer, 1024, format, args );
+00339         va_end( args );
+00340 
+00341         errorMessage ("(%s), node (%s), line (%d) :\n%s", filename, xmlNode->name, (int)xmlNode->content, buffer);
+00342 }
+
+


Field Documentation

+

+ + + + +
+ + +
std::map<std::string, std::string> NLLIGO::CLigoConfig::_ContextFilesLookup [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 131 of file ligo_config.h. +

+Referenced by readPrimitiveClass().

+

+ + + + +
+ + +
std::vector<std::string> NLLIGO::CLigoConfig::_Contexts [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 128 of file ligo_config.h. +

+Referenced by getContextString(), read(), and readPrimitiveClass().

+

+ + + + +
+ + +
std::map<std::string, CPrimitiveClass> NLLIGO::CLigoConfig::_PrimitiveClasses [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 125 of file ligo_config.h. +

+Referenced by getPrimitiveClass(), getPrimitiveColor(), isPrimitiveDeletable(), isPrimitiveLinked(), read(), and readPrimitiveClass().

+

+ + + + +
+ + +
std::vector<CPrimitiveConfigurations> NLLIGO::CLigoConfig::_PrimitiveConfigurations [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 134 of file ligo_config.h. +

+Referenced by getPrimitiveConfiguration(), read(), and readPrimitiveClass().

+

+ + + + +
+ + +
float NLLIGO::CLigoConfig::CellSize +
+
+ + + + + +
+   + + +

+Size of a cell of the ligoscape in meter. +

+ +

+Definition at line 69 of file ligo_config.h. +

+Referenced by NLLIGO::CZoneTemplate::build(), NLLIGO::CZoneEdge::build(), NLLIGO::CZoneEdge::buildMatrix(), NLLIGO::CZoneEdge::invert(), and NLLIGO::CZoneEdge::isSymetrical().

+

+ + + + +
+ + +
std::string NLLIGO::CLigoConfig::PrimitiveClassFilename +
+
+ + + + + +
+   + + +

+The ligo class file. +

+ +

+Definition at line 78 of file ligo_config.h. +

+Referenced by read().

+

+ + + + +
+ + +
float NLLIGO::CLigoConfig::Snap +
+
+ + + + + +
+   + + +

+Snap precision for vertex position checking in meter. +

+ +

+Definition at line 72 of file ligo_config.h. +

+Referenced by NLLIGO::CZoneTemplate::build(), NLLIGO::CZoneEdge::build(), NLLIGO::CZoneEdge::isSymetrical(), NLLIGO::CZoneEdge::isTheSame(), and read().

+

+ + + + +
+ + +
uint NLLIGO::CLigoConfig::ZoneSnapShotRes +
+
+ + + + + +
+   + + +

+Zone snap shot resolution. +

+ +

+Definition at line 75 of file ligo_config.h. +

+Referenced by read().

+


The documentation for this class was generated from the following files: +
Generated on Tue Mar 16 12:47:30 2004 for NeL by + +doxygen +1.3.6
+ + -- cgit v1.2.1