#include <primitive.h>
Inheritance diagram for NLLIGO::CPrimNode:
Properties | |
bool | addPropertyByName (const char *property_name, IProperty *result) |
uint | getNumProperty () const |
virtual uint | getNumVector () const=0 |
virtual const CPrimVector * | getPrimVector () const=0 |
bool | getProperty (uint index, std::string &property_name, IProperty *&result) |
bool | getProperty (uint index, std::string &property_name, const IProperty *&result) const |
bool | getPropertyByName (const char *property_name, NLMISC::CRGBA &result) const |
bool | getPropertyByName (const char *property_name, const std::vector< std::string > *&result) const |
bool | getPropertyByName (const char *property_name, std::string &result) const |
bool | getPropertyByName (const char *property_name, std::vector< std::string > *&result) const |
bool | getPropertyByName (const char *property_name, std::string *&result) const |
bool | getPropertyByName (const char *property_name, IProperty *&result) const |
bool | getPropertyByName (const char *property_name, const IProperty *&result) const |
void | removeProperties () |
bool | removeProperty (uint index) |
bool | removePropertyByName (const char *property_name) |
virtual void | write (xmlNodePtr xmlNode, const char *filename) const |
Public Types | |
enum | { NotAnArray, AtTheEnd = 0xffffffff } |
Public Member Functions | |
virtual IPrimitive * | copy () const |
virtual std::string | getClassName ()=0 |
virtual CPrimVector * | getPrimVector () |
virtual bool | read (xmlNodePtr xmlNode, const char *filename, uint version, CLigoConfig &config) |
Data Fields | |
bool | Expanded |
virtual NLMISC_DECLARE_CLASS(CPrimNode) private const CPrimVector | getPrimVector )() const |
std::string | Layer |
std::string | Name |
|
Definition at line 165 of file primitive.h.
00166 { 00167 NotAnArray, 00168 AtTheEnd = 0xffffffff, 00169 }; |
|
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 } |
|
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 398 of file primitive.cpp.
00399 { 00400 return new CPrimNode (*this); 00401 } |
|
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 } |
|
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 } |
|
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 } |
|
Implemented in NLAIAGENT::CNumericIndex, NLAIC::IPointerGestion, NLAIC::CIdentType, and CAutomataDesc. Referenced by NLMISC::CClassRegistry::checkObject(), and NL3D::GetTextureSize(). |
|
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 }
|
|
Get a num properties Definition at line 1721 of file primitive.cpp. References NLLIGO::IPrimitive::_Properties, and uint.
01722 {
01723 return _Properties.size ();
01724 }
|
|
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. Implemented in NLLIGO::CPrimPoint, NLLIGO::CPrimPath, and NLLIGO::CPrimZone. Referenced by NLSOUND::CBackgroundSoundManager::loadSoundsFromPrimitives(). |
|
Get a child primitive Definition at line 199 of file primitive.h.
00200 {
00201 return _Parent;
00202 }
|
|
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 }
|
|
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. Implemented in NLLIGO::CPrimPoint, NLLIGO::CPrimPath, and NLLIGO::CPrimZone. |
|
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. |
|
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 } |
|
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 } |
|
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 } |
|
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 } |
|
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 } |
|
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 } |
|
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 } |
|
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 } |
|
|
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 } |
|
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 370 of file primitive.cpp. References uint.
00371 {
00372 return IPrimitive::read (xmlNode, filename, version, config);
00373 }
|
|
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 } |
|
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 } |
|
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 } |
|
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 } |
|
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 } |
|
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 in NLLIGO::CPrimPoint, NLLIGO::CPrimPath, and NLLIGO::CPrimZone. Definition at line 1627 of file primitive.cpp. References NLLIGO::IPrimitive::_Properties, NLMISC::CRGBA::A, NLMISC::CRGBA::B, NLLIGO::CPropertyColor::Color, NLLIGO::IPrimitive::Expanded, NLMISC::CRGBA::G, NLMISC::CRGBA::R, NLLIGO::CPropertyString::String, NLLIGO::CPropertyStringArray::StringArray, NLMISC::toString(), and uint.
01628 { 01629 // Save the expanded flag 01630 if (!Expanded) 01631 xmlSetProp (xmlNode, (const xmlChar*)"EXPANDED", (const xmlChar*)"false"); 01632 01633 // Set the type 01634 xmlSetProp (xmlNode, (const xmlChar*)"TYPE", (const xmlChar*)(const_cast<IPrimitive*> (this)->getClassName ().c_str ())); 01635 01636 // Save the properties 01637 std::map<std::string, IProperty*>::const_iterator ite = _Properties.begin (); 01638 while (ite != _Properties.end ()) 01639 { 01640 // Not a default property ? 01641 if (!ite->second->Default) 01642 { 01643 // Create new nodes 01644 xmlNodePtr propNode = xmlNewChild ( xmlNode, NULL, (const xmlChar*)"PROPERTY", NULL); 01645 xmlNodePtr nameNode = xmlNewChild ( propNode, NULL, (const xmlChar*)"NAME", NULL); 01646 xmlNodePtr textNode = xmlNewText ((const xmlChar *)(ite->first.c_str ())); 01647 xmlAddChild (nameNode, textNode); 01648 01649 // Type 01650 const CPropertyString *str = dynamic_cast<const CPropertyString *> (ite->second); 01651 if (str) 01652 { 01653 // Set the type 01654 xmlSetProp (propNode, (const xmlChar*)"TYPE", (const xmlChar*)"string"); 01655 01656 // Create new nodes 01657 xmlNodePtr stringNode = xmlNewChild ( propNode, NULL, (const xmlChar*)"STRING", NULL); 01658 xmlNodePtr textNode = xmlNewText ((const xmlChar *)(str->String.c_str ())); 01659 xmlAddChild (stringNode, textNode); 01660 } 01661 else 01662 { 01663 // Should be an array 01664 const CPropertyStringArray *array = dynamic_cast<const CPropertyStringArray *> (ite->second); 01665 if (array) 01666 { 01667 // Set the type 01668 xmlSetProp (propNode, (const xmlChar*)"TYPE", (const xmlChar*)"string_array"); 01669 01670 // For each strings in the array 01671 for (uint i=0; i<array->StringArray.size (); i++) 01672 { 01673 // Create new nodes 01674 xmlNodePtr stringNode = xmlNewChild ( propNode, NULL, (const xmlChar*)"STRING", NULL); 01675 xmlNodePtr textNode = xmlNewText ((const xmlChar *)(array->StringArray[i].c_str ())); 01676 xmlAddChild (stringNode, textNode); 01677 } 01678 } 01679 else 01680 { 01681 // Should be a color 01682 const CPropertyColor *color = safe_cast<const CPropertyColor *> (ite->second); 01683 01684 // Set the type 01685 xmlSetProp (propNode, (const xmlChar*)"TYPE", (const xmlChar*)"color"); 01686 01687 // Create new nodes 01688 xmlNodePtr colorNode = xmlNewChild ( propNode, NULL, (const xmlChar*)"COLOR", NULL); 01689 xmlSetProp (colorNode, (const xmlChar*)"R", (const xmlChar*)toString (color->Color.R).c_str ()); 01690 xmlSetProp (colorNode, (const xmlChar*)"G", (const xmlChar*)toString (color->Color.G).c_str ()); 01691 xmlSetProp (colorNode, (const xmlChar*)"B", (const xmlChar*)toString (color->Color.B).c_str ()); 01692 xmlSetProp (colorNode, (const xmlChar*)"A", (const xmlChar*)toString (color->Color.A).c_str ()); 01693 } 01694 } 01695 } 01696 01697 ite++; 01698 } 01699 01700 // Save the children 01701 for (uint i=0; i<_Children.size (); i++) 01702 { 01703 // New node 01704 xmlNodePtr childNode = xmlNewChild ( xmlNode, NULL, (const xmlChar*)"CHILD", NULL); 01705 01706 // Write it 01707 _Children[i]->write (childNode, filename); 01708 } 01709 } |
|
Definition at line 163 of file primitive.h. Referenced by NLLIGO::IPrimitive::operator=(), NLLIGO::IPrimitive::read(), and NLLIGO::IPrimitive::write(). |
|
Definition at line 391 of file primitive.cpp.
00392 {
00393 return NULL;
00394 }
|
|
Definition at line 159 of file primitive.h. Referenced by NLLIGO::CPrimitives::convertPrimitive(), and NLLIGO::IPrimitive::operator=(). |
|
Definition at line 160 of file primitive.h. Referenced by NLLIGO::CPrimitives::convertAddPrimitive(), and NLLIGO::IPrimitive::operator=(). |