NLLIGO::CPrimPath Class Reference

#include <primitive.h>

Inheritance diagram for NLLIGO::CPrimPath:

NLLIGO::IPrimitive NLMISC::IClassable

Public Types

enum  { NotAnArray, AtTheEnd = 0xffffffff }

Public Member Functions

virtual std::string getClassName ()=0
 NLMISC_DECLARE_CLASS (CPrimPath)
void serial (NLMISC::IStream &f)

Data Fields

bool Expanded
std::string Layer
std::string Name
std::vector< CPrimVectorVPoints

Private Member Functions

virtual IPrimitivecopy () const
virtual uint getNumVector () const
virtual CPrimVectorgetPrimVector ()
virtual const CPrimVectorgetPrimVector () const
virtual bool read (xmlNodePtr xmlNode, const char *filename, uint version, CLigoConfig &config)
virtual void write (xmlNodePtr xmlNode, const char *filename) const

Member Enumeration Documentation

anonymous enum [inherited]
 

Enumeration values:
NotAnArray 
AtTheEnd 

Definition at line 165 of file primitive.h.

00166         {
00167                 NotAnArray,
00168                 AtTheEnd = 0xffffffff,
00169         };


Member Function Documentation

bool NLLIGO::IPrimitive::addPropertyByName const char *  property_name,
IProperty result
[inherited]
 

Add a property If the property already exist, the method does nothing and returns false. The pointer will be deleted by the primitive using the ::delete operator.

Definition at line 1384 of file primitive.cpp.

References NLLIGO::IPrimitive::_Properties.

Referenced by NLLIGO::CPrimitives::convertAddPrimitive(), NLLIGO::CPrimitives::convertPrimitive(), and NLLIGO::IPrimitive::read().

01385 {
01386         bool inserted = _Properties.insert (std::map<std::string, IProperty*>::value_type (property_name, result)).second;
01387         if (inserted)
01388         {
01389                 return true;
01390         }
01391         return false;
01392 }

NLLIGO::IPrimitive * NLLIGO::CPrimPath::copy  )  const [private, virtual]
 

Add a property If the property already exist, the method does nothing and returns false. The pointer will be deleted by the primitive using the ::delete operator.

Implements NLLIGO::IPrimitive.

Definition at line 531 of file primitive.cpp.

00532 {
00533         return new CPrimPath (*this);
00534 }

bool NLLIGO::IPrimitive::getChild IPrimitive *&  result,
uint  childId
[inherited]
 

Get a child primitive

Definition at line 1303 of file primitive.cpp.

References nlwarning, and uint.

01304 {
01305         if (childId < _Children.size ())
01306         {
01307                 result = _Children[childId];
01308                 return true;
01309         }
01310         else
01311         {
01312                 nlwarning ("NLLIGO::IPrimitive::getChild : invalid index (index : %d, size %d).", childId, _Children.size ());
01313         }
01314         return false;
01315 }

bool NLLIGO::IPrimitive::getChild const IPrimitive *&  result,
uint  childId
const [inherited]
 

Get a child primitive

Definition at line 1287 of file primitive.cpp.

References nlwarning, and uint.

Referenced by NLLIGO::CPrimitives::convertPrimitive(), NLSOUND::CBackgroundSoundManager::loadAudioFromPrimitives(), NLSOUND::CBackgroundSoundManager::loadEffectsFromPrimitives(), NLSOUND::CBackgroundSoundManager::loadSamplesFromPrimitives(), and NLSOUND::CBackgroundSoundManager::loadSoundsFromPrimitives().

01288 {
01289         if (childId < _Children.size ())
01290         {
01291                 result = _Children[childId];
01292                 return true;
01293         }
01294         else
01295         {
01296                 nlwarning ("NLLIGO::IPrimitive::getChild : invalid index (index : %d, size %d).", childId, _Children.size ());
01297         }
01298         return false;
01299 }

bool NLLIGO::IPrimitive::getChildId uint childId,
const IPrimitive child
const [inherited]
 

Get the id of the child, return 0xffffffff if not found

Definition at line 1713 of file primitive.cpp.

References NLLIGO::IPrimitive::_ChildId, and uint.

01714 {
01715         childId = child->_ChildId;
01716         return true;
01717 }

virtual std::string NLMISC::IClassable::getClassName  )  [pure virtual, inherited]
 

Implemented in NLAIAGENT::CNumericIndex, NLAIC::IPointerGestion, NLAIC::CIdentType, and CAutomataDesc.

Referenced by NLMISC::CClassRegistry::checkObject(), and NL3D::GetTextureSize().

uint NLLIGO::IPrimitive::getNumChildren  )  const [inline, inherited]
 

Get the children primitive count

Definition at line 183 of file primitive.h.

References uint.

Referenced by NLLIGO::CPrimitives::convertPrimitive(), NLSOUND::CBackgroundSoundManager::loadAudioFromPrimitives(), NLSOUND::CBackgroundSoundManager::loadEffectsFromPrimitives(), NLSOUND::CBackgroundSoundManager::loadSamplesFromPrimitives(), and NLSOUND::CBackgroundSoundManager::loadSoundsFromPrimitives().

00184         {
00185                 return _Children.size ();
00186         }

uint NLLIGO::IPrimitive::getNumProperty  )  const [inherited]
 

Get a num properties

Definition at line 1721 of file primitive.cpp.

References NLLIGO::IPrimitive::_Properties, and uint.

01722 {
01723         return _Properties.size ();
01724 }

uint NLLIGO::CPrimPath::getNumVector  )  const [private, virtual]
 

Add a property If the property already exist, the method does nothing and returns false. The pointer will be deleted by the primitive using the ::delete operator.

Implements NLLIGO::IPrimitive.

Definition at line 517 of file primitive.cpp.

References uint, and VPoints.

00518 {
00519         return VPoints.size ();
00520 }

const IPrimitive* NLLIGO::IPrimitive::getParent  )  const [inline, inherited]
 

Get a child primitive

Definition at line 199 of file primitive.h.

00200         {
00201                 return _Parent;
00202         }

IPrimitive* NLLIGO::IPrimitive::getParent  )  [inline, inherited]
 

Get the parent primtive

Definition at line 195 of file primitive.h.

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

00196         {
00197                 return _Parent;
00198         }

CPrimVector * NLLIGO::CPrimPath::getPrimVector  )  [private, virtual]
 

Add a property If the property already exist, the method does nothing and returns false. The pointer will be deleted by the primitive using the ::delete operator.

Implements NLLIGO::IPrimitive.

Definition at line 538 of file primitive.cpp.

References VPoints.

00539 {
00540         return &(VPoints[0]);
00541 }

const CPrimVector * NLLIGO::CPrimPath::getPrimVector  )  const [private, virtual]
 

Add a property If the property already exist, the method does nothing and returns false. The pointer will be deleted by the primitive using the ::delete operator.

Implements NLLIGO::IPrimitive.

Definition at line 524 of file primitive.cpp.

References VPoints.

00525 {
00526         return &(VPoints[0]);
00527 }

bool NLLIGO::IPrimitive::getProperty uint  index,
std::string &  property_name,
IProperty *&  result
[inherited]
 

Get a properties by its index This is method (iterate a list) is slower than getPropertyByName (look up in a map).

Definition at line 1081 of file primitive.cpp.

References NLLIGO::IPrimitive::_Properties, index, nlwarning, and uint.

01082 {
01083         // Look for the property
01084         std::map<std::string, IProperty*>::iterator ite = _Properties.begin ();
01085         while (ite != _Properties.end ())
01086         {
01087                 if (index == 0)
01088                 {
01089                         property_name = ite->first;
01090                         result = ite->second;
01091                         return true;
01092                 }
01093                 index--;
01094                 ite ++;
01095         }
01096         nlwarning ("NLLIGO::IPrimitive::getProperty : invalid index (index : %d, size : %d).", index, _Properties.size ());
01097         return false;
01098 }

bool NLLIGO::IPrimitive::getProperty uint  index,
std::string &  property_name,
const IProperty *&  result
const [inherited]
 

Get a properties by its index This is method (iterate a list) is slower than getPropertyByName (look up in a map).

Definition at line 1060 of file primitive.cpp.

References NLLIGO::IPrimitive::_Properties, index, nlwarning, and uint.

01061 {
01062         // Look for the property
01063         std::map<std::string, IProperty*>::const_iterator ite = _Properties.begin ();
01064         while (ite != _Properties.end ())
01065         {
01066                 if (index == 0)
01067                 {
01068                         property_name = ite->first;
01069                         result = ite->second;
01070                         return true;
01071                 }
01072                 index--;
01073                 ite ++;
01074         }
01075         nlwarning ("NLLIGO::IPrimitive::getProperty : invalid index (index : %d, size : %d).", index, _Properties.size ());
01076         return false;
01077 }

bool NLLIGO::IPrimitive::getPropertyByName const char *  property_name,
NLMISC::CRGBA result
const [inherited]
 

Get a color property with its name. Return false if the property is not found or is not a string array property.

Definition at line 1218 of file primitive.cpp.

References NLLIGO::CPropertyColor::Color, NLLIGO::IPrimitive::getPropertyByName(), and nlwarning.

01219 {
01220         // Get the property
01221         IProperty *prop;
01222         if (getPropertyByName (property_name, prop))
01223         {
01224                 const CPropertyColor *colorProp = dynamic_cast<const CPropertyColor *> (prop);
01225                 if (colorProp)
01226                 {
01227                         result = colorProp->Color;
01228                         return true;
01229                 }
01230                 else
01231                 {
01232                         nlwarning ("NLLIGO::IPrimitive::getPropertyByName : property (%s) in not a color.", property_name);
01233                 }
01234         }
01235         return false;
01236 }

bool NLLIGO::IPrimitive::getPropertyByName const char *  property_name,
const std::vector< std::string > *&  result
const [inherited]
 

Get a string array property with its name. Return false if the property is not found or is not a string array property.

Definition at line 1196 of file primitive.cpp.

References NLLIGO::IPrimitive::getPropertyByName(), nlwarning, and NLLIGO::CPropertyStringArray::StringArray.

01197 {
01198         // Get the property
01199         IProperty *prop;
01200         if (getPropertyByName (property_name, prop))
01201         {
01202                 const CPropertyStringArray *strProp = dynamic_cast<const CPropertyStringArray *> (prop);
01203                 if (strProp)
01204                 {
01205                         result = &(strProp->StringArray);
01206                         return true;
01207                 }
01208                 else
01209                 {
01210                         nlwarning ("NLLIGO::IPrimitive::getPropertyByName : property (%s) in not a string.", property_name);
01211                 }
01212         }
01213         return false;
01214 }

bool NLLIGO::IPrimitive::getPropertyByName const char *  property_name,
std::string &  result
const [inherited]
 

Get a string property with its name. Return false if the property is not found or is not a string property.

Definition at line 1152 of file primitive.cpp.

References NLLIGO::IPrimitive::getPropertyByName(), nlwarning, and NLLIGO::CPropertyString::String.

01153 {
01154         // Get the property
01155         const IProperty *prop;
01156         if (getPropertyByName (property_name, prop))
01157         {
01158                 const CPropertyString *strProp = dynamic_cast<const CPropertyString *> (prop);
01159                 if (strProp)
01160                 {
01161                         result = strProp->String;
01162                         return true;
01163                 }
01164                 else
01165                 {
01166                         nlwarning ("NLLIGO::IPrimitive::getPropertyByName : property (%s) in not a string.", property_name);
01167                 }
01168         }
01169         return false;
01170 }

bool NLLIGO::IPrimitive::getPropertyByName const char *  property_name,
std::vector< std::string > *&  result
const [inherited]
 

Get a string array property with its name. Return false if the property is not found or is not a string array property.

Definition at line 1174 of file primitive.cpp.

References NLLIGO::IPrimitive::getPropertyByName(), nlwarning, and NLLIGO::CPropertyStringArray::StringArray.

01175 {
01176         // Get the property
01177         IProperty *prop;
01178         if (getPropertyByName (property_name, prop))
01179         {
01180                 CPropertyStringArray *strProp = dynamic_cast<CPropertyStringArray *> (prop);
01181                 if (strProp)
01182                 {
01183                         result = &(strProp->StringArray);
01184                         return true;
01185                 }
01186                 else
01187                 {
01188                         nlwarning ("NLLIGO::IPrimitive::getPropertyByName : property (%s) in not a string.", property_name);
01189                 }
01190         }
01191         return false;
01192 }

bool NLLIGO::IPrimitive::getPropertyByName const char *  property_name,
std::string *&  result
const [inherited]
 

Get a string property with its name. Return false if the property is not found or is not a string property.

Definition at line 1130 of file primitive.cpp.

References NLLIGO::IPrimitive::getPropertyByName(), nlwarning, and NLLIGO::CPropertyString::String.

01131 {
01132         // Get the property
01133         IProperty *prop;
01134         if (getPropertyByName (property_name, prop))
01135         {
01136                 CPropertyString *strProp = dynamic_cast<CPropertyString *> (prop);
01137                 if (strProp)
01138                 {
01139                         result = &(strProp->String);
01140                         return true;
01141                 }
01142                 else
01143                 {
01144                         nlwarning ("NLLIGO::IPrimitive::getPropertyByName : property (%s) in not a string.", property_name);
01145                 }
01146         }
01147         return false;
01148 }

bool NLLIGO::IPrimitive::getPropertyByName const char *  property_name,
IProperty *&  result
const [inherited]
 

Get a property with its name

Definition at line 1116 of file primitive.cpp.

References NLLIGO::IPrimitive::_Properties.

01117 {
01118         // Look for the property
01119         std::map<std::string, IProperty*>::const_iterator ite = _Properties.find (property_name);
01120         if (ite != _Properties.end ())
01121         {
01122                 result = ite->second;
01123                 return true;
01124         }
01125         return false;
01126 }

bool NLLIGO::IPrimitive::getPropertyByName const char *  property_name,
const IProperty *&  result
const [inherited]
 

Get a property with its name

Definition at line 1102 of file primitive.cpp.

References NLLIGO::IPrimitive::_Properties.

Referenced by NLLIGO::CPrimitiveConfigurations::belong(), NLLIGO::CLigoConfig::canBeChild(), NLLIGO::CLigoConfig::canBeRoot(), NLLIGO::CPrimitives::convertPrimitive(), NLLIGO::CLigoConfig::getPrimitiveClass(), NLLIGO::CLigoConfig::getPrimitiveColor(), NLLIGO::IPrimitive::getPropertyByName(), NLLIGO::CLigoConfig::isPrimitiveDeletable(), NLLIGO::CLigoConfig::isPrimitiveLinked(), NLSOUND::CBackgroundSoundManager::loadAudioFromPrimitives(), NLSOUND::CBackgroundSoundManager::loadEffectsFromPrimitives(), NLSOUND::CBackgroundSoundManager::loadSamplesFromPrimitives(), NLSOUND::CBackgroundSoundManager::loadSoundsFromPrimitives(), NLLIGO::IPrimitive::read(), and NLLIGO::CPrimitiveClass::CParameter::translateAutoname().

01103 {
01104         // Look for the property
01105         std::map<std::string, IProperty*>::const_iterator ite = _Properties.find (property_name);
01106         if (ite != _Properties.end ())
01107         {
01108                 result = ite->second;
01109                 return true;
01110         }
01111         return false;
01112 }

bool NLLIGO::IPrimitive::insertChild IPrimitive primitive,
uint  index = AtTheEnd
[inherited]
 

Insert a child primitive before the index. The pointer will be deleted by the parent primitive using the ::delete operator. return false if the index is invalid

Definition at line 1349 of file primitive.cpp.

References NLLIGO::IPrimitive::_Parent, NLLIGO::IPrimitive::AtTheEnd, index, uint, and NLLIGO::IPrimitive::updateChildId().

Referenced by NLLIGO::CPrimitives::convertAddPrimitive(), NLLIGO::CPrimitives::convertPrimitive(), and NLLIGO::IPrimitive::read().

01350 {
01351         // At the end ?
01352         if (index == AtTheEnd)
01353                 index = _Children.size ();
01354 
01355         // Index valid ?
01356         if (index>_Children.size ())
01357                 return false;
01358 
01359         // Insert
01360         _Children.insert (_Children.begin () + index, primitive);
01361 
01362         // Update child id
01363         updateChildId (index);
01364 
01365         // Link to the parent
01366         primitive->_Parent = this;
01367 
01368         return true;
01369 }

NLLIGO::CPrimPath::NLMISC_DECLARE_CLASS CPrimPath   ) 
 

bool NLLIGO::CPrimPath::read xmlNodePtr  xmlNode,
const char *  filename,
uint  version,
CLigoConfig config
[private, virtual]
 

Add a property If the property already exist, the method does nothing and returns false. The pointer will be deleted by the primitive using the ::delete operator.

Reimplemented from NLLIGO::IPrimitive.

Definition at line 545 of file primitive.cpp.

References NLLIGO::ReadVector(), uint, and VPoints.

00546 {
00547         // Read points
00548         VPoints.clear ();
00549         VPoints.reserve (CIXml::countChildren (xmlNode, "PT"));
00550         xmlNodePtr ptNode = CIXml::getFirstChildNode (xmlNode, "PT");
00551         if (ptNode)
00552         {
00553                 do
00554                 {
00555                         // Read a vector
00556                         VPoints.push_back (CPrimVector ());
00557                         if (!ReadVector (VPoints.back (), filename, ptNode))
00558                                 return false;
00559                 }
00560                 while ((ptNode = CIXml::getNextChildNode (ptNode, "PT")));
00561         }
00562 
00563         return IPrimitive::read (xmlNode, filename, version, config);
00564 }

bool NLLIGO::IPrimitive::removeChild uint  childId  )  [inherited]
 

Remove a child primitive

Definition at line 1319 of file primitive.cpp.

References nlwarning, uint, and NLLIGO::IPrimitive::updateChildId().

01320 {
01321         if (childId < _Children.size ())
01322         {
01323                 delete _Children[childId];
01324                 _Children.erase (_Children.begin()+childId);
01325                 updateChildId (childId);
01326                 return true;
01327         }
01328         else
01329         {
01330                 nlwarning ("NLLIGO::IPrimitive::removeChild : invalid index (index : %d, size %d).", childId, _Children.size ());
01331         }
01332         return false;
01333 }

void NLLIGO::IPrimitive::removeChildren  )  [inherited]
 

Remove all children primitives

Definition at line 1337 of file primitive.cpp.

References uint.

Referenced by NLLIGO::CPrimitives::convert(), NLLIGO::IPrimitive::operator=(), NLLIGO::CPrimitives::read(), and NLLIGO::IPrimitive::~IPrimitive().

01338 {
01339         // Erase children
01340         for (uint i=0; i<_Children.size (); i++)
01341         {
01342                 delete _Children[i];
01343         }
01344         _Children.clear ();
01345 }

void NLLIGO::IPrimitive::removeProperties  )  [inherited]
 

Remove all the properties

Definition at line 1274 of file primitive.cpp.

References NLLIGO::IPrimitive::_Properties.

Referenced by NLLIGO::CPrimitives::convert(), NLLIGO::IPrimitive::operator=(), NLLIGO::CPrimitives::read(), and NLLIGO::IPrimitive::~IPrimitive().

01275 {
01276         std::map<std::string, IProperty*>::iterator ite = _Properties.begin ();
01277         while (ite != _Properties.end ())
01278         {
01279                 delete ite->second;
01280                 ite++;
01281         }
01282         _Properties.clear ();
01283 }

bool NLLIGO::IPrimitive::removeProperty uint  index  )  [inherited]
 

Remove a property This is method (iterate a list) is slower than removePropertyByName (look up in a map).

Definition at line 1240 of file primitive.cpp.

References NLLIGO::IPrimitive::_Properties, index, nlwarning, and uint.

01241 {
01242         // Look for the property
01243         std::map<std::string, IProperty*>::iterator ite = _Properties.begin ();
01244         while (ite != _Properties.end ())
01245         {
01246                 if (index == 0)
01247                 {
01248                         _Properties.erase (ite);
01249                         return true;
01250                 }
01251                 index--;
01252                 ite ++;
01253         }
01254         nlwarning ("NLLIGO::IPrimitive::removeProperty : invalid index (index : %d, size : %d).", index, _Properties.size ());
01255         return false;
01256 }

bool NLLIGO::IPrimitive::removePropertyByName const char *  property_name  )  [inherited]
 

Remove a property by its name

Definition at line 1260 of file primitive.cpp.

References NLLIGO::IPrimitive::_Properties.

01261 {
01262         // Look for the property
01263         std::map<std::string, IProperty*>::iterator ite = _Properties.find (property_name);
01264         if (ite != _Properties.end ())
01265         {
01266                 _Properties.erase (ite);
01267                 return true;
01268         }
01269         return false;
01270 }

void NLLIGO::CPrimPath::serial NLMISC::IStream f  ) 
 

Definition at line 253 of file primitive.cpp.

References VPoints.

00254 {
00255         f.xmlPushBegin ("PATH");
00256         
00257         f.xmlSetAttrib ("NAME");
00258         f.serial (Name);
00259         f.xmlSetAttrib ("LAYER");
00260         f.serial (Layer);
00261         f.xmlPushEnd ();
00262 
00263         f.serialCont (VPoints);
00264 
00265         f.xmlPop ();
00266 }

void NLLIGO::CPrimPath::write xmlNodePtr  xmlNode,
const char *  filename
const [private, virtual]
 

Add a property If the property already exist, the method does nothing and returns false. The pointer will be deleted by the primitive using the ::delete operator.

Reimplemented from NLLIGO::IPrimitive.

Definition at line 568 of file primitive.cpp.

References uint, VPoints, and NLLIGO::WriteVector().

00569 {
00570         // Save the points
00571         for (uint i=0; i<VPoints.size (); i++)
00572         {
00573                 xmlNodePtr ptNode = xmlNewChild ( xmlNode, NULL, (const xmlChar*)"PT", NULL);
00574                 WriteVector (VPoints[i], ptNode);
00575         }
00576 
00577         IPrimitive::write (xmlNode, filename);
00578 }


Field Documentation

bool NLLIGO::IPrimitive::Expanded [inherited]
 

Definition at line 163 of file primitive.h.

Referenced by NLLIGO::IPrimitive::operator=(), NLLIGO::IPrimitive::read(), and NLLIGO::IPrimitive::write().

std::string NLLIGO::IPrimitive::Layer [inherited]
 

Definition at line 159 of file primitive.h.

Referenced by NLLIGO::CPrimitives::convertPrimitive(), and NLLIGO::IPrimitive::operator=().

std::string NLLIGO::IPrimitive::Name [inherited]
 

Definition at line 160 of file primitive.h.

Referenced by NLLIGO::CPrimitives::convertAddPrimitive(), and NLLIGO::IPrimitive::operator=().

std::vector<CPrimVector> NLLIGO::CPrimPath::VPoints
 

Definition at line 405 of file primitive.h.

Referenced by getNumVector(), getPrimVector(), read(), serial(), and write().


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