#include <primitive_configuration.h>
Nevrax France
Definition at line 49 of file primitive_configuration.h.
Public Member Functions | |
bool | belong (const IPrimitive &primitive) const |
bool | read (xmlNodePtr configurationNode, const char *filename, const char *name, class CLigoConfig &config) |
Data Fields | |
NLMISC::CRGBA | Color |
std::vector< CMatchGroup > | MatchPairs |
std::string | Name |
|
Definition at line 97 of file primitive_configuration.cpp. References NLLIGO::IPrimitive::getPropertyByName(), MatchPairs, NLLIGO::CPrimitiveConfigurations::CMatchGroup::Pairs, NLMISC::strlwr(), uint, and value.
00098 { 00099 // For each match group 00100 uint group; 00101 const uint numGroup = MatchPairs.size(); 00102 for (group=0; group<numGroup; group++) 00103 { 00104 const CMatchGroup &matchGroup = MatchPairs[group]; 00105 00106 // For each rules 00107 uint rules; 00108 const uint numRules = matchGroup.Pairs.size(); 00109 for (rules=0; rules<numRules; rules++) 00110 { 00111 const std::pair<std::string, std::string> &pairs = matchGroup.Pairs[rules]; 00112 string key = strlwr(pairs.second); 00113 00114 // Get the property 00115 string value; 00116 if (primitive.getPropertyByName (pairs.first.c_str(), value)) 00117 { 00118 if (strlwr(value) == key) 00119 continue; 00120 } 00121 00122 // Get the property 00123 const std::vector<string> *array = NULL; 00124 if (primitive.getPropertyByName (pairs.first.c_str(), array) && array) 00125 { 00126 uint i; 00127 for (i=0; i<array->size(); i++) 00128 { 00129 if (strlwr((*array)[i]) == key) 00130 break; 00131 } 00132 if (i!=array->size()) 00133 continue; 00134 } 00135 00136 // Don't match 00137 break; 00138 } 00139 00140 // Match ? 00141 if (rules == numRules) 00142 return true; 00143 } 00144 return false; 00145 } |
|
Definition at line 39 of file primitive_configuration.cpp. References NLLIGO::CLigoConfig::getPropertyString(), MatchPairs, NLLIGO::CPrimitiveConfigurations::CMatchGroup::Pairs, ReadColor(), and NLLIGO::CLigoConfig::syntaxError().
00040 { 00041 // The name 00042 Name = name; 00043 00044 // Read the color 00045 ReadColor (Color, configurationNode); 00046 00047 // Get the first matching pair 00048 MatchPairs.reserve (CIXml::countChildren (configurationNode, "MATCH_GROUP")); 00049 xmlNodePtr matchGroups = CIXml::getFirstChildNode (configurationNode, "MATCH_GROUP"); 00050 if (matchGroups) 00051 { 00052 do 00053 { 00054 // Add a pair 00055 MatchPairs.push_back(CMatchGroup()); 00056 CMatchGroup &matchGroup = MatchPairs.back(); 00057 00058 // Get the first matching pair 00059 matchGroup.Pairs.reserve (CIXml::countChildren (matchGroups, "MATCH")); 00060 xmlNodePtr match = CIXml::getFirstChildNode (matchGroups, "MATCH"); 00061 if (match) 00062 { 00063 do 00064 { 00065 // Add the match 00066 matchGroup.Pairs.resize (matchGroup.Pairs.size()+1); 00067 std::pair<std::string, std::string> &pair = matchGroup.Pairs.back(); 00068 00069 // Get the match name 00070 std::string name; 00071 if (config.getPropertyString (name, filename, match, "NAME")) 00072 { 00073 pair.first = name; 00074 } 00075 else 00076 { 00077 config.syntaxError (filename, match, "Missing match name in configuration (%s)", name.c_str()); 00078 return false; 00079 } 00080 00081 // Get the match value 00082 if (config.getPropertyString (name, filename, match, "VALUE")) 00083 { 00084 pair.second = name; 00085 } 00086 } 00087 while ((match = CIXml::getNextChildNode (match, "MATCH"))); 00088 } 00089 } 00090 while ((matchGroups = CIXml::getNextChildNode (matchGroups, "MATCH_GROUP"))); 00091 } 00092 return true; 00093 } |
|
Definition at line 57 of file primitive_configuration.h. |
|
Definition at line 67 of file primitive_configuration.h. |
|
Definition at line 54 of file primitive_configuration.h. |