ligo_config.h
Go to the documentation of this file.00001
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef NL_LIGO_CONFIG_H
00025 #define NL_LIGO_CONFIG_H
00026
00027 #include "nel/misc/types_nl.h"
00028 #include "primitive_class.h"
00029 #include "primitive_configuration.h"
00030
00031 #define DEFAULT_PRIMITIVE_COLOR (CRGBA (128, 0, 0, 128))
00032
00033 namespace NLLIGO
00034 {
00035
00036 class IPrimitive;
00037 class CPrimitive;
00038
00046 class CLigoConfig
00047 {
00048 public:
00049
00050 CLigoConfig();
00051
00052 virtual ~CLigoConfig() { }
00053
00059 bool readConfigFile (const char *fileName, bool parsePrimitiveComboContent);
00060
00065 bool readPrimitiveClass (const char *fileName, bool parsePrimitiveComboContent);
00066
00067 bool reloadIndexFile(const std::string &indexFileName = std::string());
00068
00069
00071 void resetPrimitiveConfiguration ();
00072
00074
00076 float CellSize;
00077
00079 float Snap;
00080
00082 uint ZoneSnapShotRes;
00083
00085 std::string PrimitiveClassFilename;
00086
00088
00090 uint32 getDynamicAliasSize() const;
00092 uint32 getDynamicAliasMask() const;
00094 uint32 getStaticAliasSize() const;
00096 uint32 getStaticAliasMask() const;
00098 uint32 buildAlias(uint32 staticPart, uint32 dynamicPart, bool warnIfOverload = true) const;
00100 void registerFileToStaticAliasTranslation(const std::string &fileName, uint32 staticPart);
00102 virtual uint32 getFileStaticAliasMapping(const std::string &fileName) const;
00104 const std::string &getFileNameForStaticAlias(uint32 staticAlias) const;
00106 bool isFileStaticAliasMapped(const std::string &fileName) const;
00108 std::string aliasToString(uint32 fullAlias);
00110 uint32 aliasFromString(std::string fullAlias);
00111
00112
00113
00114 const CPrimitiveClass *getPrimitiveClass (const NLLIGO::IPrimitive &primitive) const;
00115
00116
00117 const CPrimitiveClass *getPrimitiveClass (const char *className) const;
00118
00119
00120 NLMISC::CRGBA getPrimitiveColor (const NLLIGO::IPrimitive &primitive);
00121
00122
00123 bool isStaticChild (const NLLIGO::IPrimitive &primitive);
00124
00125
00126 bool isPrimitiveLinked (const NLLIGO::IPrimitive &primitive);
00127
00128
00129 const NLLIGO::IPrimitive *getLinkedPrimitive (const NLLIGO::IPrimitive &primitive) const;
00130
00131
00132 const NLLIGO::IPrimitive *getPreviousLinkedPrimitive (const NLLIGO::IPrimitive &primitive) const;
00133
00134
00135 bool isPrimitiveDeletable (const NLLIGO::IPrimitive &primitive);
00136
00137
00138 bool canBeChild (const NLLIGO::IPrimitive &child, const NLLIGO::IPrimitive &parent);
00139
00140
00141 bool canBeRoot (const NLLIGO::IPrimitive &primitive);
00142
00143
00144 bool getPropertyString (std::string &result, const char *filename, xmlNodePtr xmlNode, const char *propName);
00145
00146
00147 void syntaxError (const char *filename, xmlNodePtr xmlNode, const char *format, ...);
00148 virtual void errorMessage (const char *format, ... );
00149
00150
00151 const std::vector<std::string> &getContextString () const;
00152
00153
00154 const std::vector<CPrimitiveConfigurations> &getPrimitiveConfiguration() const
00155 {
00156 return _PrimitiveConfigurations;
00157 }
00158
00159
00160
00161
00162 void updateDynamicAliasBitCount(uint32 newDynamicAliasBitCount);
00163
00164 private:
00165
00166
00167 bool initPrimitiveClass (const char *filename);
00168
00169
00170 std::map<std::string, CPrimitiveClass> _PrimitiveClasses;
00171
00172
00173 std::vector<std::string> _Contexts;
00174
00175
00176 std::map<std::string, std::string> _ContextFilesLookup;
00177
00178
00179 std::vector<CPrimitiveConfigurations> _PrimitiveConfigurations;
00180
00181
00182 uint32 _DynamicAliasBitCount;
00183
00185 std::string _IndexFileName;
00186
00187 std::map<std::string, uint32> _StaticAliasFileMapping;
00188 };
00189
00190 }
00191
00192 #endif // NL_LIGO_CONFIG_H
00193
00194