OgrePrerequisites.h
Go to the documentation of this file.
00001 /*-------------------------------------------------------------------------
00002 This source file is a part of OGRE
00003 (Object-oriented Graphics Rendering Engine)
00004 
00005 For the latest info, see http://www.ogre3d.org/
00006 
00007 Copyright (c) 2000-2013 Torus Knot Software Ltd
00008 Permission is hereby granted, free of charge, to any person obtaining a copy
00009 of this software and associated documentation files (the "Software"), to deal
00010 in the Software without restriction, including without limitation the rights
00011 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00012 copies of the Software, and to permit persons to whom the Software is
00013 furnished to do so, subject to the following conditions:
00014 
00015 The above copyright notice and this permission notice shall be included in
00016 all copies or substantial portions of the Software.
00017 
00018 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00019 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00020 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00021 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00022 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00023 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00024 THE SOFTWARE
00025 -------------------------------------------------------------------------*/
00026 #ifndef __OgrePrerequisites_H__
00027 #define __OgrePrerequisites_H__
00028 
00029 // Platform-specific stuff
00030 #include "OgrePlatform.h"
00031 
00032 #include <string>
00033 
00034 // configure memory tracking
00035 #if OGRE_DEBUG_MODE 
00036 #   if OGRE_MEMORY_TRACKER_DEBUG_MODE
00037 #        define OGRE_MEMORY_TRACKER 1
00038 #   else
00039 #        define OGRE_MEMORY_TRACKER 0
00040 #   endif
00041 #else
00042 #   if OGRE_MEMORY_TRACKER_RELEASE_MODE
00043 #        define OGRE_MEMORY_TRACKER 1
00044 #   else
00045 #        define OGRE_MEMORY_TRACKER 0
00046 #   endif
00047 #endif
00048 
00049 namespace Ogre {
00050     // Define ogre version
00051     #define OGRE_VERSION_MAJOR 1
00052     #define OGRE_VERSION_MINOR 9
00053     #define OGRE_VERSION_PATCH 0
00054     #define OGRE_VERSION_SUFFIX ""
00055     #define OGRE_VERSION_NAME "Ghadamon"
00056 
00057     #define OGRE_VERSION    ((OGRE_VERSION_MAJOR << 16) | (OGRE_VERSION_MINOR << 8) | OGRE_VERSION_PATCH)
00058 
00059     // define the real number values to be used
00060     // default to use 'float' unless precompiler option set
00061     #if OGRE_DOUBLE_PRECISION == 1
00062 
00065         typedef double Real;
00066     #else
00067 
00070         typedef float Real;
00071     #endif
00072 
00073     #if OGRE_COMPILER == OGRE_COMPILER_GNUC && OGRE_COMP_VER >= 310 && !defined(STLPORT)
00074     #   if OGRE_COMP_VER >= 430
00075     #       define HashMap ::std::tr1::unordered_map
00076     #       define HashSet ::std::tr1::unordered_set
00077     #    else
00078     #       define HashMap ::__gnu_cxx::hash_map
00079     #       define HashSet ::__gnu_cxx::hash_set
00080     #    endif
00081     #elif OGRE_COMPILER == OGRE_COMPILER_CLANG
00082     #    if defined(_LIBCPP_VERSION)
00083     #       define HashMap ::std::unordered_map
00084     #       define HashSet ::std::unordered_set
00085     #    else
00086     #       define HashMap ::std::tr1::unordered_map
00087     #       define HashSet ::std::tr1::unordered_set
00088     #    endif
00089     #else
00090     #   if OGRE_COMPILER == OGRE_COMPILER_MSVC && !defined(_STLP_MSVC)
00091     #       if _MSC_FULL_VER >= 150030729 // VC++ 9.0 SP1+
00092     #           define HashMap ::std::tr1::unordered_map
00093     #           define HashSet ::std::tr1::unordered_set
00094     #       elif OGRE_THREAD_PROVIDER == 1
00095     #           define HashMap ::boost::unordered_map
00096     #           define HashSet ::boost::unordered_set
00097     #       else
00098     #           define HashMap ::std::unordered_map
00099     #           define HashSet ::std::unordered_set
00100     #       endif
00101     #   else
00102     #       define HashMap ::std::unordered_map
00103     #       define HashSet ::std::unordered_set
00104     #   endif
00105     #endif
00106 
00107     #define OGRE_DEFINE_STATIC_LOCAL(type, name, arguments) \
00108         static type& name = *new type arguments
00109 
00112     typedef unsigned char uchar;
00113     typedef unsigned short ushort;
00114     typedef unsigned int uint;
00115     typedef unsigned long ulong;
00116 
00117 // Pre-declare classes
00118 // Allows use of pointers in header files without including individual .h
00119 // so decreases dependencies between files
00120     class Angle;
00121     class Animation;
00122     class AnimationState;
00123     class AnimationStateSet;
00124     class AnimationTrack;
00125     class Archive;
00126     class ArchiveFactory;
00127     class ArchiveManager;
00128     class AutoParamDataSource;
00129     class AxisAlignedBox;
00130     class AxisAlignedBoxSceneQuery;
00131     class Billboard;
00132     class BillboardChain;
00133     class BillboardSet;
00134     class Bone;
00135     class Camera;
00136     class Codec;
00137     class ColourValue;
00138     class ConfigDialog;
00139     template <typename T> class Controller;
00140     template <typename T> class ControllerFunction;
00141     class ControllerManager;
00142     template <typename T> class ControllerValue;
00143     class DefaultWorkQueue;
00144     class Degree;
00145     class DepthBuffer;
00146     class DynLib;
00147     class DynLibManager;
00148     class EdgeData;
00149     class EdgeListBuilder;
00150     class Entity;
00151     class ErrorDialog;
00152     class ExternalTextureSourceManager;
00153     class Factory;
00154     struct FrameEvent;
00155     class FrameListener;
00156     class Frustum;
00157     class GpuProgram;
00158     class GpuProgramManager;
00159     class GpuProgramUsage;
00160     class HardwareIndexBuffer;
00161     class HardwareOcclusionQuery;
00162     class HardwareVertexBuffer;
00163     class HardwarePixelBuffer;
00164     class HardwarePixelBufferSharedPtr;
00165     class HighLevelGpuProgram;
00166     class HighLevelGpuProgramManager;
00167     class HighLevelGpuProgramFactory;
00168     class IndexData;
00169     class InstanceBatch;
00170     class InstanceBatchHW;
00171     class InstanceBatchHW_VTF;
00172     class InstanceBatchShader;
00173     class InstanceBatchVTF;
00174     class InstanceManager;
00175     class InstancedEntity;
00176     class IntersectionSceneQuery;
00177     class IntersectionSceneQueryListener;
00178     class Image;
00179     class KeyFrame;
00180     class Light;
00181     class Log;
00182     class LogManager;
00183     class LodStrategy;
00184     class ManualResourceLoader;
00185     class ManualObject;
00186     class Material;
00187     class MaterialManager;
00188     class Math;
00189     class Matrix3;
00190     class Matrix4;
00191     class MemoryManager;
00192     class Mesh;
00193     class MeshSerializer;
00194     class MeshSerializerImpl;
00195     class MeshManager;
00196     class MovableObject;
00197     class MovablePlane;
00198     class Node;
00199     class NodeAnimationTrack;
00200     class NodeKeyFrame;
00201     class NumericAnimationTrack;
00202     class NumericKeyFrame;
00203     class Particle;
00204     class ParticleAffector;
00205     class ParticleAffectorFactory;
00206     class ParticleEmitter;
00207     class ParticleEmitterFactory;
00208     class ParticleSystem;
00209     class ParticleSystemManager;
00210     class ParticleSystemRenderer;
00211     class ParticleSystemRendererFactory;
00212     class ParticleVisualData;
00213     class Pass;
00214     class PatchMesh;
00215     class PixelBox;
00216     class Plane;
00217     class PlaneBoundedVolume;
00218     class Plugin;
00219     class PMWorker;
00220     class PMInjector;
00221     class Pose;
00222     class ProgressiveMeshGenerator;
00223     class Profile;
00224     class Profiler;
00225     class Quaternion;
00226     class Radian;
00227     class Ray;
00228     class RaySceneQuery;
00229     class RaySceneQueryListener;
00230     class Renderable;
00231     class RenderPriorityGroup;
00232     class RenderQueue;
00233     class RenderQueueGroup;
00234     class RenderQueueInvocation;
00235     class RenderQueueInvocationSequence;
00236     class RenderQueueListener;
00237     class RenderObjectListener;
00238     class RenderSystem;
00239     class RenderSystemCapabilities;
00240     class RenderSystemCapabilitiesManager;
00241     class RenderSystemCapabilitiesSerializer;
00242     class RenderTarget;
00243     class RenderTargetListener;
00244     class RenderTexture;
00245     class MultiRenderTarget;
00246     class RenderWindow;
00247     class RenderOperation;
00248     class Resource;
00249     class ResourceBackgroundQueue;
00250     class ResourceGroupManager;
00251     class ResourceManager;
00252     class RibbonTrail;
00253     class Root;
00254     class SceneManager;
00255     class SceneManagerEnumerator;
00256     class SceneNode;
00257     class SceneQuery;
00258     class SceneQueryListener;
00259     class ScriptCompiler;
00260     class ScriptCompilerManager;
00261     class ScriptLoader;
00262     class Serializer;
00263     class ShadowCaster;
00264     class ShadowRenderable;
00265     class ShadowTextureManager;
00266     class SimpleRenderable;
00267     class SimpleSpline;
00268     class Skeleton;
00269     class SkeletonInstance;
00270     class SkeletonManager;
00271     class Sphere;
00272     class SphereSceneQuery;
00273     class StaticGeometry;
00274     class StreamSerialiser;
00275     class StringConverter;
00276     class StringInterface;
00277     class SubEntity;
00278     class SubMesh;
00279     class TagPoint;
00280     class Technique;
00281     class TempBlendedBufferInfo;
00282     class ExternalTextureSource;
00283     class TextureUnitState;
00284     class Texture;
00285     class TextureManager;
00286     class TransformKeyFrame;
00287     class Timer;
00288     class UserObjectBindings;
00289     class Vector2;
00290     class Vector3;
00291     class Vector4;
00292     class Viewport;
00293     class VertexAnimationTrack;
00294     class VertexBufferBinding;
00295     class VertexData;
00296     class VertexDeclaration;
00297     class VertexMorphKeyFrame;
00298     class WireBoundingBox;
00299     class WorkQueue;
00300     class Compositor;
00301     class CompositorManager;
00302     class CompositorChain;
00303     class CompositorInstance;
00304     class CompositorLogic;
00305     class CompositionTechnique;
00306     class CompositionPass;
00307     class CompositionTargetPass;
00308     class CustomCompositionPass;
00309 
00310     template<typename T> class SharedPtr;
00311     typedef SharedPtr<Compositor> CompositorPtr;
00312     typedef SharedPtr<GpuProgram> GpuProgramPtr;
00313     typedef SharedPtr<HighLevelGpuProgram> HighLevelGpuProgramPtr;
00314     typedef SharedPtr<Material> MaterialPtr;
00315     typedef SharedPtr<Mesh> MeshPtr;
00316     typedef SharedPtr<PatchMesh> PatchMeshPtr;
00317     typedef SharedPtr<Resource> ResourcePtr;
00318     typedef SharedPtr<Skeleton> SkeletonPtr;
00319     typedef SharedPtr<Texture> TexturePtr;
00320 }
00321 
00322 /* Include all the standard header *after* all the configuration
00323 settings have been made.
00324 */
00325 #include "OgreStdHeaders.h"
00326 #include "OgreMemoryAllocatorConfig.h"
00327 
00328 
00329 namespace Ogre
00330 {
00331 #if OGRE_STRING_USE_CUSTOM_MEMORY_ALLOCATOR
00332     typedef std::basic_string<char, std::char_traits<char>, STLAllocator<char,GeneralAllocPolicy > >        _StringBase;
00333     typedef std::basic_stringstream<char,std::char_traits<char>,STLAllocator<char,GeneralAllocPolicy > >    _StringStreamBase;
00334 
00335     #define StdStringT(T) std::basic_string<T, std::char_traits<T>, std::allocator<T> > 
00336     #define CustomMemoryStringT(T) std::basic_string<T, std::char_traits<T>, STLAllocator<T,GeneralAllocPolicy> >   
00337 
00338     template<typename T>
00339     bool operator <(const CustomMemoryStringT(T)& l,const StdStringT(T)& o)
00340     {
00341         return l.compare(0,l.length(),o.c_str(),o.length())<0;
00342     }
00343     template<typename T>
00344     bool operator <(const StdStringT(T)& l,const CustomMemoryStringT(T)& o)
00345     {
00346         return l.compare(0,l.length(),o.c_str(),o.length())<0;
00347     }
00348     template<typename T>
00349     bool operator <=(const CustomMemoryStringT(T)& l,const StdStringT(T)& o)
00350     {
00351         return l.compare(0,l.length(),o.c_str(),o.length())<=0;
00352     }
00353     template<typename T>
00354     bool operator <=(const StdStringT(T)& l,const CustomMemoryStringT(T)& o)
00355     {
00356         return l.compare(0,l.length(),o.c_str(),o.length())<=0;
00357     }
00358     template<typename T>
00359     bool operator >(const CustomMemoryStringT(T)& l,const StdStringT(T)& o)
00360     {
00361         return l.compare(0,l.length(),o.c_str(),o.length())>0;
00362     }
00363     template<typename T>
00364     bool operator >(const StdStringT(T)& l,const CustomMemoryStringT(T)& o)
00365     {
00366         return l.compare(0,l.length(),o.c_str(),o.length())>0;
00367     }
00368     template<typename T>
00369     bool operator >=(const CustomMemoryStringT(T)& l,const StdStringT(T)& o)
00370     {
00371         return l.compare(0,l.length(),o.c_str(),o.length())>=0;
00372     }
00373     template<typename T>
00374     bool operator >=(const StdStringT(T)& l,const CustomMemoryStringT(T)& o)
00375     {
00376         return l.compare(0,l.length(),o.c_str(),o.length())>=0;
00377     }
00378 
00379     template<typename T>
00380     bool operator ==(const CustomMemoryStringT(T)& l,const StdStringT(T)& o)
00381     {
00382         return l.compare(0,l.length(),o.c_str(),o.length())==0;
00383     }
00384     template<typename T>
00385     bool operator ==(const StdStringT(T)& l,const CustomMemoryStringT(T)& o)
00386     {
00387         return l.compare(0,l.length(),o.c_str(),o.length())==0;
00388     }
00389 
00390     template<typename T>
00391     bool operator !=(const CustomMemoryStringT(T)& l,const StdStringT(T)& o)
00392     {
00393         return l.compare(0,l.length(),o.c_str(),o.length())!=0;
00394     }
00395     template<typename T>
00396     bool operator !=(const StdStringT(T)& l,const CustomMemoryStringT(T)& o)
00397     {
00398         return l.compare(0,l.length(),o.c_str(),o.length())!=0;
00399     }
00400 
00401     template<typename T>
00402     CustomMemoryStringT(T) operator +=(const CustomMemoryStringT(T)& l,const StdStringT(T)& o)
00403     {
00404         return CustomMemoryStringT(T)(l)+=o.c_str();
00405     }
00406     template<typename T>
00407     CustomMemoryStringT(T) operator +=(const StdStringT(T)& l,const CustomMemoryStringT(T)& o)
00408     {
00409         return CustomMemoryStringT(T)(l.c_str())+=o.c_str();
00410     }
00411 
00412     template<typename T>
00413     CustomMemoryStringT(T) operator +(const CustomMemoryStringT(T)& l,const StdStringT(T)& o)
00414     {
00415         return CustomMemoryStringT(T)(l)+=o.c_str();
00416     }
00417 
00418     template<typename T>
00419     CustomMemoryStringT(T) operator +(const StdStringT(T)& l,const CustomMemoryStringT(T)& o)
00420     {
00421         return CustomMemoryStringT(T)(l.c_str())+=o.c_str();
00422     }
00423 
00424     template<typename T>
00425     CustomMemoryStringT(T) operator +(const T* l,const CustomMemoryStringT(T)& o)
00426     {
00427         return CustomMemoryStringT(T)(l)+=o;
00428     }
00429 
00430     #undef StdStringT
00431     #undef CustomMemoryStringT
00432 
00433 #else
00434     typedef std::string _StringBase;
00435     typedef std::basic_stringstream<char,std::char_traits<char>,std::allocator<char> > _StringStreamBase;
00436 
00437 #endif
00438 
00439     typedef _StringBase String;
00440     typedef _StringStreamBase StringStream;
00441     typedef StringStream stringstream;
00442 
00443 }
00444 
00445 #if OGRE_STRING_USE_CUSTOM_MEMORY_ALLOCATOR 
00446 namespace std 
00447 {
00448 #if (OGRE_COMPILER == OGRE_COMPILER_GNUC && OGRE_COMP_VER >= 430) || OGRE_COMPILER == OGRE_COMPILER_CLANG && !defined(STLPORT) && __cplusplus < 201103L
00449     namespace tr1
00450     {
00451 #endif
00452     template <> struct hash<Ogre::String>
00453     {
00454     public :
00455         size_t operator()(const Ogre::String &str ) const
00456         {
00457             size_t _Val = 2166136261U;
00458             size_t _First = 0;
00459             size_t _Last = str.size();
00460             size_t _Stride = 1 + _Last / 10;
00461 
00462             for(; _First < _Last; _First += _Stride)
00463                 _Val = 16777619U * _Val ^ (size_t)str[_First];
00464             return (_Val);
00465         }
00466     };
00467 #if (OGRE_COMPILER == OGRE_COMPILER_GNUC && OGRE_COMP_VER >= 430) || OGRE_COMPILER == OGRE_COMPILER_CLANG && !defined(STLPORT) && __cplusplus < 201103L
00468     }
00469 #endif
00470 }
00471 #endif
00472 
00473 //for stl container
00474 namespace Ogre
00475 { 
00476     template <typename T, typename A = STLAllocator<T, GeneralAllocPolicy> > 
00477     struct deque 
00478     { 
00479 #if OGRE_CONTAINERS_USE_CUSTOM_MEMORY_ALLOCATOR
00480         typedef typename std::deque<T, A> type;    
00481         typedef typename std::deque<T, A>::iterator iterator;
00482         typedef typename std::deque<T, A>::const_iterator const_iterator;
00483 #else
00484         typedef typename std::deque<T> type;
00485         typedef typename std::deque<T>::iterator iterator;
00486         typedef typename std::deque<T>::const_iterator const_iterator;
00487 #endif
00488     }; 
00489 
00490     template <typename T, typename A = STLAllocator<T, GeneralAllocPolicy> > 
00491     struct vector 
00492     { 
00493 #if OGRE_CONTAINERS_USE_CUSTOM_MEMORY_ALLOCATOR
00494         typedef typename std::vector<T, A> type;
00495         typedef typename std::vector<T, A>::iterator iterator;
00496         typedef typename std::vector<T, A>::const_iterator const_iterator;
00497 #else
00498         typedef typename std::vector<T> type;
00499         typedef typename std::vector<T>::iterator iterator;
00500         typedef typename std::vector<T>::const_iterator const_iterator;
00501 #endif
00502     }; 
00503 
00504     template <typename T, typename A = STLAllocator<T, GeneralAllocPolicy> > 
00505     struct list 
00506     { 
00507 #if OGRE_CONTAINERS_USE_CUSTOM_MEMORY_ALLOCATOR
00508         typedef typename std::list<T, A> type;
00509         typedef typename std::list<T, A>::iterator iterator;
00510         typedef typename std::list<T, A>::const_iterator const_iterator;
00511 #else
00512         typedef typename std::list<T> type;
00513         typedef typename std::list<T>::iterator iterator;
00514         typedef typename std::list<T>::const_iterator const_iterator;
00515 #endif
00516     }; 
00517 
00518     template <typename T, typename P = std::less<T>, typename A = STLAllocator<T, GeneralAllocPolicy> > 
00519     struct set 
00520     { 
00521 #if OGRE_CONTAINERS_USE_CUSTOM_MEMORY_ALLOCATOR
00522         typedef typename std::set<T, P, A> type;
00523         typedef typename std::set<T, P, A>::iterator iterator;
00524         typedef typename std::set<T, P, A>::const_iterator const_iterator;
00525 #else
00526         typedef typename std::set<T, P> type;
00527         typedef typename std::set<T, P>::iterator iterator;
00528         typedef typename std::set<T, P>::const_iterator const_iterator;
00529 #endif
00530     }; 
00531 
00532     template <typename K, typename V, typename P = std::less<K>, typename A = STLAllocator<std::pair<const K, V>, GeneralAllocPolicy> > 
00533     struct map 
00534     { 
00535 #if OGRE_CONTAINERS_USE_CUSTOM_MEMORY_ALLOCATOR
00536         typedef typename std::map<K, V, P, A> type;
00537         typedef typename std::map<K, V, P, A>::iterator iterator;
00538         typedef typename std::map<K, V, P, A>::const_iterator const_iterator;
00539 #else
00540         typedef typename std::map<K, V, P> type;
00541         typedef typename std::map<K, V, P>::iterator iterator;
00542         typedef typename std::map<K, V, P>::const_iterator const_iterator;
00543 #endif
00544     }; 
00545 
00546     template <typename K, typename V, typename P = std::less<K>, typename A = STLAllocator<std::pair<const K, V>, GeneralAllocPolicy> > 
00547     struct multimap 
00548     { 
00549 #if OGRE_CONTAINERS_USE_CUSTOM_MEMORY_ALLOCATOR
00550         typedef typename std::multimap<K, V, P, A> type;
00551         typedef typename std::multimap<K, V, P, A>::iterator iterator;
00552         typedef typename std::multimap<K, V, P, A>::const_iterator const_iterator;
00553 #else
00554         typedef typename std::multimap<K, V, P> type;
00555         typedef typename std::multimap<K, V, P>::iterator iterator;
00556         typedef typename std::multimap<K, V, P>::const_iterator const_iterator;
00557 #endif
00558     }; 
00559 
00560 } // Ogre
00561 
00562 #endif // __OgrePrerequisites_H__
00563 
00564 

Copyright © 2012 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Mon Jul 27 2020 13:40:45