#include <primitive.h>
Inheritance diagram for NLLIGO::CPrimPoint:

Public Types | |
| enum | { NotAnArray, AtTheEnd = 0xffffffff } |
Public Member Functions | |
| CPrimPoint () | |
| virtual std::string | getClassName ()=0 |
| NLMISC_DECLARE_CLASS (CPrimPoint) | |
| void | serial (NLMISC::IStream &f) |
Data Fields | |
| float | Angle |
| bool | Expanded |
| std::string | Layer |
| std::string | Name |
| CPrimVector | Point |
Private Member Functions | |
| virtual IPrimitive * | copy () const |
| virtual uint | getNumVector () const |
| virtual CPrimVector * | getPrimVector () |
| virtual const CPrimVector * | getPrimVector () const |
| virtual bool | read (xmlNodePtr xmlNode, const char *filename, uint version, CLigoConfig &config) |
| virtual void | write (xmlNodePtr xmlNode, const char *filename) const |
|
|
Definition at line 165 of file primitive.h.
00166 {
00167 NotAnArray,
00168 AtTheEnd = 0xffffffff,
00169 };
|
|
|
Definition at line 362 of file primitive.h. References Angle. Referenced by copy().
00363 {
00364 Angle = 0;
00365 }
|
|
||||||||||||
|
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 460 of file primitive.cpp. References CPrimPoint().
00461 {
00462 return new CPrimPoint (*this);
00463 }
|
|
||||||||||||
|
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. Implements NLLIGO::IPrimitive. Definition at line 439 of file primitive.cpp. References uint.
00440 {
00441 return 1;
00442 }
|
|
|
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. Implements NLLIGO::IPrimitive. Definition at line 453 of file primitive.cpp.
00454 {
00455 return &Point;
00456 }
|
|
|
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 446 of file primitive.cpp.
00447 {
00448 return &Point;
00449 }
|
|
||||||||||||||||
|
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 467 of file primitive.cpp. References Angle, NLLIGO::GetFirstChildNode(), NLLIGO::ReadFloat(), NLLIGO::ReadVector(), and uint.
00468 {
00469 // Read points
00470 xmlNodePtr ptNode = GetFirstChildNode (xmlNode, filename, "PT");
00471 if (ptNode)
00472 {
00473 // Read a vector
00474 if (!ReadVector (Point, filename, ptNode))
00475 return false;
00476
00477 ptNode = CIXml::getFirstChildNode (xmlNode, "ANGLE");
00478 if (ptNode)
00479 {
00480 // Read a float
00481 if (!ReadFloat ("VALUE", Angle, filename, ptNode))
00482 return false;
00483 }
00484 else
00485 Angle = 0;
00486 }
00487 else
00488 {
00489 return false;
00490 }
00491
00492 return IPrimitive::read (xmlNode, filename, version, config);
00493 }
|
|
|
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 }
|
|
|
Definition at line 232 of file primitive.cpp. References Angle.
00233 {
00234 f.xmlPushBegin ("POINT");
00235
00236 f.xmlSetAttrib ("NAME");
00237 f.serial (Name);
00238 f.xmlSetAttrib ("LAYER");
00239 f.serial (Layer);
00240 f.xmlPushEnd ();
00241
00242 f.serial (Point);
00243
00244 if (f.isReading ())
00245 {
00246 Angle = 0;
00247 }
00248
00249 f.xmlPop ();
00250 }
|
|
||||||||||||
|
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 497 of file primitive.cpp. References Angle, NLLIGO::WriteFloat(), and NLLIGO::WriteVector().
00498 {
00499 // Save the point
00500 xmlNodePtr ptNode = xmlNewChild ( xmlNode, NULL, (const xmlChar*)"PT", NULL);
00501 WriteVector (Point, ptNode);
00502
00503 // Save the angle
00504 if (Angle != 0)
00505 {
00506 xmlNodePtr ptNode = xmlNewChild ( xmlNode, NULL, (const xmlChar*)"ANGLE", NULL);
00507 WriteFloat ("VALUE", Angle, ptNode);
00508 }
00509
00510 IPrimitive::write (xmlNode, filename);
00511 }
|
|
|
Definition at line 369 of file primitive.h. Referenced by CPrimPoint(), read(), serial(), and write(). |
|
|
Definition at line 163 of file primitive.h. Referenced by NLLIGO::IPrimitive::operator=(), NLLIGO::IPrimitive::read(), and NLLIGO::IPrimitive::write(). |
|
|
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=(). |
|
|
Definition at line 368 of file primitive.h. |
1.3.6