ligo_config.h

Go to the documentation of this file.
00001 
00005 /* Copyright, 2000, 2001 Nevrax Ltd.
00006  *
00007  * This file is part of NEVRAX NEL.
00008  * NEVRAX NEL is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation; either version 2, or (at your option)
00011  * any later version.
00012 
00013  * NEVRAX NEL is distributed in the hope that it will be useful, but
00014  * WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00016  * General Public License for more details.
00017 
00018  * You should have received a copy of the GNU General Public License
00019  * along with NEVRAX NEL; see the file COPYING. If not, write to the
00020  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00021  * MA 02111-1307, USA.
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     // Get a primitive class
00114     const CPrimitiveClass       *getPrimitiveClass (const NLLIGO::IPrimitive &primitive) const;
00115 
00116     // Get a primitive class
00117     const CPrimitiveClass       *getPrimitiveClass (const char *className) const;
00118 
00119     // Get the primitive color
00120     NLMISC::CRGBA               getPrimitiveColor (const NLLIGO::IPrimitive &primitive);
00121 
00122     // Is the primitive deletable ?
00123     bool isStaticChild (const NLLIGO::IPrimitive &primitive);
00124 
00125     // Is the primitive linked to its brother primitive ?
00126     bool isPrimitiveLinked (const NLLIGO::IPrimitive &primitive);
00127 
00128     // Return the next primitive linked to 'primitive', or NULL
00129     const NLLIGO::IPrimitive *getLinkedPrimitive (const NLLIGO::IPrimitive &primitive) const;
00130 
00131     // Return the previous primitive linked to 'primitive', or NULL
00132     const NLLIGO::IPrimitive *getPreviousLinkedPrimitive (const NLLIGO::IPrimitive &primitive) const;
00133 
00134     // Is the primitive deletable ?
00135     bool isPrimitiveDeletable (const NLLIGO::IPrimitive &primitive);
00136 
00137     // Is the child primitive can be a child of the parent primitive ?
00138     bool canBeChild (const NLLIGO::IPrimitive &child, const NLLIGO::IPrimitive &parent);
00139 
00140     // Is the primitive a root primitive ?
00141     bool canBeRoot (const NLLIGO::IPrimitive &primitive);
00142 
00143     // Read a property from an XML file
00144     bool getPropertyString (std::string &result, const char *filename, xmlNodePtr xmlNode, const char *propName);
00145 
00146     // Output error message
00147     void syntaxError (const char *filename, xmlNodePtr xmlNode, const char *format, ...);
00148     virtual void errorMessage (const char *format, ... );
00149 
00150     // Access to the config string
00151     const std::vector<std::string> &getContextString () const;
00152 
00153     // Access the primitive configuration
00154     const std::vector<CPrimitiveConfigurations> &getPrimitiveConfiguration() const
00155     {
00156         return _PrimitiveConfigurations;
00157     }
00158 
00159     // Update the DynamicAlias bit count that was previously defined in the config file.
00160     // The _StaticAliasFileMapping is updated in order that full alias stay the same.
00161     // All previous DynamicAlias must fit in the new DynamicAliasBitCount
00162     void updateDynamicAliasBitCount(uint32 newDynamicAliasBitCount);
00163 
00164 private:
00165 
00166     // Init primitive class manager
00167     bool        initPrimitiveClass (const char *filename);
00168 
00169     // The primitive class manager
00170     std::map<std::string, CPrimitiveClass>  _PrimitiveClasses;
00171 
00172     // The context strings
00173     std::vector<std::string>    _Contexts;
00174 
00175     // The file context look up
00176     std::map<std::string, std::string>  _ContextFilesLookup;
00177 
00178     // The primitive configurations
00179     std::vector<CPrimitiveConfigurations>   _PrimitiveConfigurations;
00180 
00181     // Dynamic alias bit count
00182     uint32              _DynamicAliasBitCount;
00183 
00185     std::string         _IndexFileName;
00186     // Static alias part file mapping : filename -> staticAliasPart
00187     std::map<std::string, uint32>       _StaticAliasFileMapping;
00188 };
00189 
00190 }
00191 
00192 #endif // NL_LIGO_CONFIG_H
00193 
00194 /* End of ligo_config.h */

Generated on Thu Jan 7 08:26:22 2010 for NeL by  doxygen 1.6.1