NLLIGO::CPrimitiveClass Class Reference

#include <primitive_class.h>


Detailed Description

Class of primitive
Author:
Cyril 'Hulud' Corvazier

Nevrax France

Date:
2002

Definition at line 50 of file primitive_class.h.

Public Types

enum  TType {
  Node, Point, Path, Bitmap,
  Zone
}

Public Member Functions

 CPrimitiveClass ()
 Constructor.

bool read (xmlNodePtr primitiveNode, const char *filename, const char *className, std::set< std::string > &contextStrings, std::map< std::string, std::string > &contextFilesLookup, NLLIGO::CLigoConfig &config)

Data Fields

bool AutoInit
 Auto init ?

bool Collision
 Collision ?

NLMISC::CRGBA Color
 Color.

bool Deletable
 Deletable ?

std::vector< CChildDynamicChildren
std::string FileExtension
 Filename extension (for type File).

std::string FileType
 File type (for type File).

std::vector< CChildGeneratedChildren
bool LinkBrothers
 Link children ?

std::string Name
 Class name.

bool Numberize
 Numberize on copy ?

std::vector< CParameterParameters
 Parameters.

bool ShowArrow
 Show arrow ?

std::vector< CChildStaticChildren
enum NLLIGO::CPrimitiveClass::TType Type


Member Enumeration Documentation

enum NLLIGO::CPrimitiveClass::TType
 

Enumeration values:
Node 
Point 
Path 
Bitmap 
Zone 

Definition at line 55 of file primitive_class.h.

00056         {
00057                 Node,
00058                 Point,
00059                 Path,
00060                 Bitmap,
00061                 Zone
00062         }                                               Type;


Constructor & Destructor Documentation

CPrimitiveClass::CPrimitiveClass  ) 
 

Constructor.

Definition at line 38 of file primitive_class.cpp.

00039 {
00040 }


Member Function Documentation

bool CPrimitiveClass::read xmlNodePtr  primitiveNode,
const char *  filename,
const char *  className,
std::set< std::string > &  contextStrings,
std::map< std::string, std::string > &  contextFilesLookup,
NLLIGO::CLigoConfig config
 

Definition at line 193 of file primitive_class.cpp.

References AutoInit, NLLIGO::CPrimitiveClass::CParameter::Autoname, Bitmap, Collision, NLLIGO::CPrimitiveClass::CParameter::ComboValues, NLLIGO::CPrimitiveClass::CInitParameters::DefaultValue, Deletable, NLLIGO::CPrimitiveClass::CParameter::DisplayHS, DynamicChildren, NLLIGO::CPrimitiveClass::CParameter::FileExtension, FileExtension, NLLIGO::CPrimitiveClass::CParameter::Filename, FileType, NLLIGO::CPrimitiveClass::CParameter::Folder, GeneratedChildren, NLLIGO::CLigoConfig::getPropertyString(), LinkBrothers, NLLIGO::CPrimitiveClass::CParameter::Lookup, NLLIGO::CPrimitiveClass::CInitParameters::Name, Node, Numberize, Parameters, ReadBool(), ReadChild(), ReadColor(), ReadInt(), NLLIGO::CPrimitiveClass::CParameter::ReadOnly, ShowArrow, NLLIGO::CPrimitiveClass::CParameter::SortEntries, StaticChildren, NLMISC::strlwr(), NLLIGO::CLigoConfig::syntaxError(), NLLIGO::CPrimitiveClass::CParameter::Type, type, uint, value, NLLIGO::CPrimitiveClass::CParameter::CConstStringValue::Values, NLLIGO::CPrimitiveClass::CParameter::Visible, and NLLIGO::CPrimitiveClass::CParameter::WidgetHeight.

00195 {
00196         // The name
00197         Name = className;
00198 
00199         // Read the type
00200         std::string type;
00201         if (config.getPropertyString (type, filename, primitiveNode, "TYPE"))
00202         {
00203                 // Good type ?
00204                 if (type == "node")
00205                         Type = Node;
00206                 else if (type == "point")
00207                         Type = Point;
00208                 else if (type == "path")
00209                         Type = Path;
00210                 else if (type == "zone")
00211                         Type = Zone;
00212                 else if (type == "bitmap")
00213                         Type = Bitmap;
00214                 else 
00215                 {
00216                         config.syntaxError (filename, primitiveNode, "Unknown primitive type (%s)", type.c_str ());
00217                         goto failed;
00218                 }
00219 
00220                 // Read the color
00221                 ReadColor (Color, primitiveNode);
00222 
00223                 // Autoinit
00224                 AutoInit = false;
00225                 ReadBool ("AUTO_INIT", AutoInit, primitiveNode, filename, config);
00226                 
00227                 // Deletable
00228                 Deletable = true;
00229                 ReadBool ("DELETABLE", Deletable, primitiveNode, filename, config);
00230 
00231                 // File extension
00232                 FileExtension = "";
00233                 CIXml::getPropertyString (FileExtension, primitiveNode, "FILE_EXTENSION");
00234 
00235                 // File type
00236                 FileType = "";
00237                 CIXml::getPropertyString (FileType, primitiveNode, "FILE_TYPE");
00238 
00239                 // Collision
00240                 Collision = false;
00241                 ReadBool ("COLLISION", Collision, primitiveNode, filename, config);
00242 
00243                 // LinkBrothers
00244                 LinkBrothers = false;
00245                 ReadBool ("LINK_BROTHERS", LinkBrothers, primitiveNode, filename, config);
00246 
00247                 // ShowArrow
00248                 ShowArrow = true;
00249                 ReadBool ("SHOW_ARROW", ShowArrow, primitiveNode, filename, config);
00250                 
00251                 // Numberize when copy the primitive
00252                 Numberize = true;
00253                 ReadBool ("NUMBERIZE", Numberize, primitiveNode, filename, config);
00254 
00255                 // Read the parameters
00256                 xmlNodePtr paramNode = CIXml::getFirstChildNode (primitiveNode, "PARAMETER");
00257                 if (paramNode)
00258                 {
00259                         do
00260                         {
00261                                 // Add a parameter
00262                                 Parameters.push_back (CParameter ());
00263 
00264                                 // The parameter ref
00265                                 CParameter &parameter = Parameters.back ();
00266 
00267                                 // Read the property name
00268                                 if (config.getPropertyString (type, filename, paramNode, "NAME"))
00269                                 {
00270                                         // Set the name
00271                                         parameter.Name = type;
00272 
00273                                         // Read the type
00274                                         if (config.getPropertyString (type, filename, paramNode, "TYPE"))
00275                                         {
00276                                                 // Good type ?
00277                                                 if (type == "boolean")
00278                                                         parameter.Type = CParameter::Boolean;
00279                                                 else if (type == "const_string")
00280                                                         parameter.Type = CParameter::ConstString;
00281                                                 else if (type == "string")
00282                                                         parameter.Type = CParameter::String;
00283                                                 else if (type == "string_array")
00284                                                         parameter.Type = CParameter::StringArray;
00285                                                 else if (type == "const_string_array")
00286                                                         parameter.Type = CParameter::ConstStringArray;
00287                                                 else
00288                                                 {
00289                                                         config.syntaxError (filename, paramNode, "Unknown primitive parameter type (%s)", type.c_str ());
00290                                                         goto failed;
00291                                                 }
00292 
00293                                                 // Visible
00294                                                 parameter.Visible = true;
00295                                                 ReadBool ("VISIBLE", parameter.Visible, paramNode, filename, config);
00296 
00297                                                 // Filename
00298                                                 parameter.Filename = false;
00299                                                 ReadBool ("FILENAME", parameter.Filename, paramNode, filename, config);
00300 
00301                                                 // Lookup
00302                                                 parameter.Lookup = false;
00303                                                 ReadBool ("LOOKUP", parameter.Lookup, paramNode, filename, config);
00304 
00305                                                 // Read only primitive
00306                                                 parameter.ReadOnly = false;
00307                                                 ReadBool ("READ_ONLY", parameter.ReadOnly, paramNode, filename, config);
00308 
00309                                                 // sort combo box entries 
00310                                                 parameter.SortEntries = false;
00311                                                 ReadBool ("SORT_ENTRIES", parameter.SortEntries, paramNode, filename, config);
00312 
00313                                                 // Display horizontal scoller in multiline edit box
00314                                                 parameter.DisplayHS = false;
00315                                                 ReadBool ("SHOW_HS", parameter.DisplayHS, paramNode, filename, config);
00316 
00317                                                 // Lookup
00318                                                 parameter.WidgetHeight = 100;
00319                                                 int temp;
00320                                                 if (ReadInt ("WIDGET_HEIGHT", temp, paramNode))
00321                                                         parameter.WidgetHeight = (uint)temp;
00322 
00323                                                 // Read the file extension
00324                                                 parameter.FileExtension = "";
00325                                                 CIXml::getPropertyString (parameter.FileExtension, paramNode, "FILE_EXTENSION");
00326                                                 parameter.FileExtension = strlwr (parameter.FileExtension);
00327 
00328                                                 // Autonaming preference
00329                                                 parameter.Autoname = "";
00330                                                 CIXml::getPropertyString (parameter.Autoname, paramNode, "AUTONAME");
00331                                                 
00332                                                 // Read the file extension
00333                                                 parameter.Folder = "";
00334                                                 CIXml::getPropertyString (parameter.Folder, paramNode, "FOLDER");
00335                                                 parameter.Folder = strlwr (parameter.Folder);
00336 
00337                                                 // Read the combo values
00338                                                 xmlNodePtr comboValueNode = CIXml::getFirstChildNode (paramNode, "COMBO_VALUES");
00339                                                 if (comboValueNode)
00340                                                 {
00341                                                         do
00342                                                         {
00343                                                                 // Read the context
00344                                                                 if (config.getPropertyString (type, filename, comboValueNode, "CONTEXT_NAME"))
00345                                                                 {
00346                                                                         // Add this context
00347                                                                         contextStrings.insert (type);
00348 
00349                                                                         // Add a combo value
00350                                                                         pair<std::map<std::string, CParameter::CConstStringValue>::iterator, bool> insertResult =
00351                                                                                 parameter.ComboValues.insert (std::map<std::string, CParameter::CConstStringValue>::value_type (type, CParameter::CConstStringValue ()));
00352 
00353                                                                         // The combo value ref
00354                                                                         CParameter::CConstStringValue &comboValue = insertResult.first->second;
00355 
00356                                                                         // Read the values
00357                                                                         xmlNodePtr comboValueValueNode = CIXml::getFirstChildNode (comboValueNode, "CONTEXT_VALUE");
00358                                                                         comboValue.Values.reserve (CIXml::countChildren (comboValueNode, "CONTEXT_VALUE"));
00359                                                                         if (comboValueValueNode)
00360                                                                         {
00361                                                                                 do
00362                                                                                 {
00363                                                                                         // Read the value 
00364                                                                                         if (config.getPropertyString (type, filename, comboValueValueNode, "VALUE"))
00365                                                                                         {
00366                                                                                                 // Add a combo box
00367                                                                                                 comboValue.Values.push_back (type);
00368                                                                                         }
00369                                                                                         else
00370                                                                                                 goto failed;
00371                                                                                 }
00372                                                                                 while ((comboValueValueNode = CIXml::getFirstChildNode (comboValueValueNode, "CONTEXT_VALUE")));
00373                                                                         }
00374                                                                 }
00375                                                                 else
00376                                                                         goto failed;
00377                                                         }
00378                                                         while ((comboValueNode = CIXml::getNextChildNode (comboValueNode, "COMBO_VALUES")));
00379                                                 }
00380 
00381                                                 // Read the combo files
00382                                                 comboValueNode = CIXml::getFirstChildNode (paramNode, "COMBO_FILES");
00383                                                 if (comboValueNode)
00384                                                 {
00385                                                         do
00386                                                         {
00387                                                                 // Read the context
00388                                                                 if (config.getPropertyString (type, filename, comboValueNode, "CONTEXT_NAME"))
00389                                                                 {
00390                                                                         // Read the path to search
00391                                                                         string path;
00392                                                                         if (config.getPropertyString (path, filename, comboValueNode, "PATH"))
00393                                                                         {
00394                                                                                 // Look for files in the path
00395                                                                                 std::vector<std::string> files;
00396                                                                                 CPath::getPathContent (path, true, false, true, files);
00397 
00398                                                                                 // Not empty ?
00399                                                                                 if (!files.empty ())
00400                                                                                 {
00401                                                                                         // Add this context
00402                                                                                         contextStrings.insert (type);
00403 
00404                                                                                         // For each file
00405                                                                                         for (uint i=0; i<files.size (); i++)
00406                                                                                         {
00407                                                                                                 // Good extension ?
00408                                                                                                 if (strlwr (NLMISC::CFile::getExtension (files[i])) == parameter.FileExtension)
00409                                                                                                 {
00410                                                                                                         // Add a combo value
00411                                                                                                         pair<std::map<std::string, CParameter::CConstStringValue>::iterator, bool> insertResult =
00412                                                                                                                 parameter.ComboValues.insert (std::map<std::string, CParameter::CConstStringValue>::value_type (type, CParameter::CConstStringValue ()));
00413 
00414                                                                                                         // The combo value ref
00415                                                                                                         CParameter::CConstStringValue &comboValue = insertResult.first->second;
00416 
00417                                                                                                         // Get the filename without extension
00418                                                                                                         string nameWithoutExt = strlwr (NLMISC::CFile::getFilenameWithoutExtension (files[i]));
00419 
00420                                                                                                         // Add the values
00421                                                                                                         comboValue.Values.push_back (nameWithoutExt);
00422 
00423                                                                                                         // Add the value for lookup
00424                                                                                                         contextFilesLookup.insert (map<string, string>::value_type (nameWithoutExt, files[i]));
00425                                                                                                 }
00426                                                                                         }
00427                                                                                 }
00428                                                                         }
00429                                                                         else
00430                                                                                 goto failed;
00431                                                                 }
00432                                                                 else
00433                                                                         goto failed;
00434                                                         }
00435                                                         while ((comboValueNode = CIXml::getNextChildNode (comboValueNode, "COMBO_FILES")));
00436                                                 }
00437 
00438                                                 // Read parameters default values
00439                                                 xmlNodePtr defaultValueNode = CIXml::getFirstChildNode (paramNode, "DEFAULT_VALUE");
00440                                                 parameter.DefaultValue.resize (CIXml::countChildren (paramNode, "DEFAULT_VALUE"));
00441                                                 uint defaultId = 0;
00442                                                 if (defaultValueNode)
00443                                                 {
00444                                                         do
00445                                                         {
00446                                                                 // Gen id flag
00447                                                                 parameter.DefaultValue[defaultId].GenID = false;
00448 
00449                                                                 // Read the gen id flag
00450                                                                 string value;
00451                                                                 if (CIXml::getPropertyString (value, defaultValueNode, "GEN_ID") && (value != "false"))
00452                                                                 {
00453                                                                         parameter.DefaultValue[defaultId].GenID = true;
00454                                                                 }
00455                                                                 else
00456                                                                 {
00457                                                                         if (config.getPropertyString (value, filename, defaultValueNode, "VALUE"))
00458                                                                         {
00459                                                                                 parameter.DefaultValue[defaultId].Name = value;
00460                                                                         }
00461                                                                         else
00462                                                                                 goto failed;
00463                                                                 }
00464                                                                 defaultId++;
00465                                                         }
00466                                                         while ((defaultValueNode = CIXml::getNextChildNode (defaultValueNode, "DEFAULT_VALUE")));
00467                                                 }
00468                                         }
00469                                         else
00470                                                 goto failed;
00471                                 }
00472                                 else
00473                                         goto failed;
00474                         }
00475                         while ((paramNode = CIXml::getNextChildNode (paramNode, "PARAMETER")));
00476                 }
00477 
00478                 // Read static children
00479                 xmlNodePtr childrenNode = CIXml::getFirstChildNode (primitiveNode, "STATIC_CHILD");
00480                 StaticChildren.reserve (CIXml::countChildren (primitiveNode, "STATIC_CHILD"));
00481                 if (childrenNode)
00482                 {
00483                         do
00484                         {
00485                                 // Add a static child
00486                                 StaticChildren.push_back (CChild ());
00487                                 
00488                                 // Child ref
00489                                 CChild &child = StaticChildren.back ();
00490 
00491                                 // Read the child
00492                                 if (!ReadChild (child, childrenNode, filename, true, config))
00493                                         goto failed;
00494                         }
00495                         while ((childrenNode = CIXml::getNextChildNode (childrenNode, "STATIC_CHILD")));
00496                 }
00497 
00498                 // Read dynamic children
00499                 childrenNode = CIXml::getFirstChildNode (primitiveNode, "DYNAMIC_CHILD");
00500                 DynamicChildren.reserve (CIXml::countChildren (primitiveNode, "DYNAMIC_CHILD"));
00501                 if (childrenNode)
00502                 {
00503                         do
00504                         {
00505                                 // Add a static child
00506                                 DynamicChildren.push_back (CChild ());
00507                                 
00508                                 // Child ref
00509                                 CChild &child = DynamicChildren.back ();
00510 
00511                                 // Read the child
00512                                 if (!ReadChild (child, childrenNode, filename, false, config))
00513                                         goto failed;
00514                         }
00515                         while ((childrenNode = CIXml::getNextChildNode (childrenNode, "DYNAMIC_CHILD")));
00516                 }
00517 
00518                 // Read generated children
00519                 childrenNode = CIXml::getFirstChildNode (primitiveNode, "GENERATED_CHILD");
00520                 GeneratedChildren.reserve (CIXml::countChildren (primitiveNode, "GENERATED_CHILD"));
00521                 if (childrenNode)
00522                 {
00523                         do
00524                         {
00525                                 // Add a static child
00526                                 GeneratedChildren.push_back (CChild ());
00527                                 
00528                                 // Child ref
00529                                 CChild &child = GeneratedChildren.back ();
00530 
00531                                 // Read the child
00532                                 if (!ReadChild (child, childrenNode, filename, false, config))
00533                                         goto failed;
00534                         }
00535                         while ((childrenNode = CIXml::getNextChildNode (childrenNode, "GENERATED_CHILD")));
00536                 }
00537 
00538                 return true;
00539         }
00540 failed:
00541         return false;
00542 }


Field Documentation

bool NLLIGO::CPrimitiveClass::AutoInit
 

Auto init ?

Definition at line 80 of file primitive_class.h.

Referenced by read().

bool NLLIGO::CPrimitiveClass::Collision
 

Collision ?

Definition at line 86 of file primitive_class.h.

Referenced by read().

NLMISC::CRGBA NLLIGO::CPrimitiveClass::Color
 

Color.

Definition at line 77 of file primitive_class.h.

bool NLLIGO::CPrimitiveClass::Deletable
 

Deletable ?

Definition at line 83 of file primitive_class.h.

Referenced by read().

std::vector<CChild> NLLIGO::CPrimitiveClass::DynamicChildren
 

Definition at line 221 of file primitive_class.h.

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

std::string NLLIGO::CPrimitiveClass::FileExtension
 

Filename extension (for type File).

Definition at line 71 of file primitive_class.h.

Referenced by read().

std::string NLLIGO::CPrimitiveClass::FileType
 

File type (for type File).

Definition at line 74 of file primitive_class.h.

Referenced by read().

std::vector<CChild> NLLIGO::CPrimitiveClass::GeneratedChildren
 

Definition at line 224 of file primitive_class.h.

Referenced by NLLIGO::CLigoConfig::canBeChild(), and read().

bool NLLIGO::CPrimitiveClass::LinkBrothers
 

Link children ?

Definition at line 89 of file primitive_class.h.

Referenced by read().

std::string NLLIGO::CPrimitiveClass::Name
 

Class name.

Definition at line 68 of file primitive_class.h.

bool NLLIGO::CPrimitiveClass::Numberize
 

Numberize on copy ?

Definition at line 95 of file primitive_class.h.

Referenced by read().

std::vector<CParameter> NLLIGO::CPrimitiveClass::Parameters
 

Parameters.

Definition at line 201 of file primitive_class.h.

Referenced by read(), NLLIGO::IPrimitive::read(), and NLLIGO::CPrimitiveClass::CParameter::translateAutoname().

bool NLLIGO::CPrimitiveClass::ShowArrow
 

Show arrow ?

Definition at line 92 of file primitive_class.h.

Referenced by read().

std::vector<CChild> NLLIGO::CPrimitiveClass::StaticChildren
 

Definition at line 218 of file primitive_class.h.

Referenced by read().

enum NLLIGO::CPrimitiveClass::TType NLLIGO::CPrimitiveClass::Type
 


The documentation for this class was generated from the following files:
Generated on Tue Mar 16 12:48:13 2004 for NeL by doxygen 1.3.6