OgrePrerequisites.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2 This source file is a part of OGRE
3 (Object-oriented Graphics Rendering Engine)
4 
5 For the latest info, see http://www.ogre3d.org/
6 
7 Copyright (c) 2000-2013 Torus Knot Software Ltd
8 Permission is hereby granted, free of charge, to any person obtaining a copy
9 of this software and associated documentation files (the "Software"), to deal
10 in the Software without restriction, including without limitation the rights
11 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 copies of the Software, and to permit persons to whom the Software is
13 furnished to do so, subject to the following conditions:
14 
15 The above copyright notice and this permission notice shall be included in
16 all copies or substantial portions of the Software.
17 
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 THE SOFTWARE
25 -------------------------------------------------------------------------*/
26 #ifndef __OgrePrerequisites_H__
27 #define __OgrePrerequisites_H__
28 
29 // Platform-specific stuff
30 #include "OgrePlatform.h"
31 
32 // Needed for OGRE_WCHAR_T_STRINGS below
33 #include <string>
34 
35 
36 // configure memory tracking
37 #if OGRE_DEBUG_MODE
38 # if OGRE_MEMORY_TRACKER_DEBUG_MODE
39 # define OGRE_MEMORY_TRACKER 1
40 # else
41 # define OGRE_MEMORY_TRACKER 0
42 # endif
43 #else
44 # if OGRE_MEMORY_TRACKER_RELEASE_MODE
45 # define OGRE_MEMORY_TRACKER 1
46 # else
47 # define OGRE_MEMORY_TRACKER 0
48 # endif
49 #endif
50 
51 
52 
53 
54 namespace Ogre {
55  // Define ogre version
56  #define OGRE_VERSION_MAJOR 1
57  #define OGRE_VERSION_MINOR 9
58  #define OGRE_VERSION_PATCH 0
59  #define OGRE_VERSION_SUFFIX "unstable"
60  #define OGRE_VERSION_NAME "Ghadamon"
61 
62  #define OGRE_VERSION ((OGRE_VERSION_MAJOR << 16) | (OGRE_VERSION_MINOR << 8) | OGRE_VERSION_PATCH)
63 
64  // define the real number values to be used
65  // default to use 'float' unless precompiler option set
66  #if OGRE_DOUBLE_PRECISION == 1
67 
70  typedef double Real;
71  #else
72 
75  typedef float Real;
76  #endif
77 
78  #if OGRE_COMPILER == OGRE_COMPILER_GNUC && OGRE_COMP_VER >= 310 && !defined(STLPORT)
79  # if OGRE_COMP_VER >= 430
80  # define HashMap ::std::tr1::unordered_map
81  # define HashSet ::std::tr1::unordered_set
82  # else
83  # define HashMap ::__gnu_cxx::hash_map
84  # define HashSet ::__gnu_cxx::hash_set
85  # endif
86  #elif OGRE_COMPILER == OGRE_COMPILER_CLANG
87  # if defined(_LIBCPP_VERSION)
88  # define HashMap ::std::unordered_map
89  # define HashSet ::std::unordered_set
90  # else
91  # define HashMap ::std::tr1::unordered_map
92  # define HashSet ::std::tr1::unordered_set
93  # endif
94  #else
95  # if OGRE_COMPILER == OGRE_COMPILER_MSVC && !defined(_STLP_MSVC)
96  # if _MSC_FULL_VER >= 150030729 // VC++ 9.0 SP1+
97  # define HashMap ::std::tr1::unordered_map
98  # define HashSet ::std::tr1::unordered_set
99  # elif OGRE_THREAD_PROVIDER == 1
100  # define HashMap ::boost::unordered_map
101  # define HashSet ::boost::unordered_set
102  # else
103  # define HashMap ::std::unordered_map
104  # define HashSet ::std::unordered_set
105  # endif
106  # else
107  # define HashMap ::std::unordered_map
108  # define HashSet ::std::unordered_set
109  # endif
110  #endif
111 
112  #define OGRE_DEFINE_STATIC_LOCAL(type, name, arguments) \
113  static type& name = *new type arguments
114 
117  typedef unsigned char uchar;
118  typedef unsigned short ushort;
119  typedef unsigned int uint;
120  typedef unsigned long ulong;
121 
122 // Pre-declare classes
123 // Allows use of pointers in header files without including individual .h
124 // so decreases dependencies between files
125  class Angle;
126  class Animation;
127  class AnimationState;
128  class AnimationStateSet;
129  class AnimationTrack;
130  class Archive;
131  class ArchiveFactory;
132  class ArchiveManager;
133  class AutoParamDataSource;
134  class AxisAlignedBox;
136  class Billboard;
137  class BillboardChain;
138  class BillboardSet;
139  class Bone;
140  class Camera;
141  class Codec;
142  class ColourValue;
143  class ConfigDialog;
144  template <typename T> class Controller;
145  template <typename T> class ControllerFunction;
146  class ControllerManager;
147  template <typename T> class ControllerValue;
148  class DefaultWorkQueue;
149  class Degree;
150  class DepthBuffer;
151  class DynLib;
152  class DynLibManager;
153  class EdgeData;
154  class EdgeListBuilder;
155  class Entity;
156  class ErrorDialog;
158  class Factory;
159  struct FrameEvent;
160  class FrameListener;
161  class Frustum;
162  class GpuProgram;
163  class GpuProgramManager;
164  class GpuProgramUsage;
165  class HardwareIndexBuffer;
167  class HardwareVertexBuffer;
168  class HardwarePixelBuffer;
170  class HighLevelGpuProgram;
173  class IndexData;
174  class InstanceBatch;
175  class InstanceBatchHW;
176  class InstanceBatchHW_VTF;
177  class InstanceBatchShader;
178  class InstanceBatchVTF;
179  class InstanceManager;
180  class InstancedEntity;
183  class Image;
184  class KeyFrame;
185  class Light;
186  class Log;
187  class LogManager;
188  class LodStrategy;
189  class ManualResourceLoader;
190  class ManualObject;
191  class Material;
192  class MaterialManager;
193  class Math;
194  class Matrix3;
195  class Matrix4;
196  class MemoryManager;
197  class Mesh;
198  class MeshSerializer;
199  class MeshSerializerImpl;
200  class MeshManager;
201  class MovableObject;
202  class MovablePlane;
203  class Node;
204  class NodeAnimationTrack;
205  class NodeKeyFrame;
206  class NumericAnimationTrack;
207  class NumericKeyFrame;
208  class Particle;
209  class ParticleAffector;
211  class ParticleEmitter;
213  class ParticleSystem;
214  class ParticleSystemManager;
217  class ParticleVisualData;
218  class Pass;
219  class PatchMesh;
220  class PixelBox;
221  class Plane;
222  class PlaneBoundedVolume;
223  class Plugin;
224  class PMWorker;
225  class PMInjector;
226  class Pose;
228  class Profile;
229  class Profiler;
230  class Quaternion;
231  class Radian;
232  class Ray;
233  class RaySceneQuery;
234  class RaySceneQueryListener;
235  class Renderable;
236  class RenderPriorityGroup;
237  class RenderQueue;
238  class RenderQueueGroup;
239  class RenderQueueInvocation;
241  class RenderQueueListener;
242  class RenderObjectListener;
243  class RenderSystem;
247  class RenderTarget;
248  class RenderTargetListener;
249  class RenderTexture;
250  class MultiRenderTarget;
251  class RenderWindow;
252  class RenderOperation;
253  class Resource;
255  class ResourceGroupManager;
256  class ResourceManager;
257  class RibbonTrail;
258  class Root;
259  class SceneManager;
261  class SceneNode;
262  class SceneQuery;
263  class SceneQueryListener;
264  class ScriptCompiler;
265  class ScriptCompilerManager;
266  class ScriptLoader;
267  class Serializer;
268  class ShadowCaster;
269  class ShadowRenderable;
270  class ShadowTextureManager;
271  class SimpleRenderable;
272  class SimpleSpline;
273  class Skeleton;
274  class SkeletonInstance;
275  class SkeletonManager;
276  class Sphere;
277  class SphereSceneQuery;
278  class StaticGeometry;
279  class StreamSerialiser;
280  class StringConverter;
281  class StringInterface;
282  class SubEntity;
283  class SubMesh;
284  class TagPoint;
285  class Technique;
286  class TempBlendedBufferInfo;
287  class ExternalTextureSource;
288  class TextureUnitState;
289  class Texture;
290  class TextureManager;
291  class TransformKeyFrame;
292  class Timer;
293  class UserObjectBindings;
294  class Vector2;
295  class Vector3;
296  class Vector4;
297  class Viewport;
298  class VertexAnimationTrack;
299  class VertexBufferBinding;
300  class VertexData;
301  class VertexDeclaration;
302  class VertexMorphKeyFrame;
303  class WireBoundingBox;
304  class WorkQueue;
305  class Compositor;
306  class CompositorManager;
307  class CompositorChain;
308  class CompositorInstance;
309  class CompositorLogic;
310  class CompositionTechnique;
311  class CompositionPass;
312  class CompositionTargetPass;
313  class CustomCompositionPass;
314 
315  template<typename T> class SharedPtr;
325 }
326 
327 /* Include all the standard header *after* all the configuration
328 settings have been made.
329 */
330 #include "OgreStdHeaders.h"
332 
333 
334 namespace Ogre
335 {
336 #if OGRE_STRING_USE_CUSTOM_MEMORY_ALLOCATOR
337  #if OGRE_WCHAR_T_STRINGS
338  typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, STLAllocator<wchar_t,GeneralAllocPolicy > > _StringBase;
339  #else
340  typedef std::basic_string<char, std::char_traits<char>, STLAllocator<char,GeneralAllocPolicy > > _StringBase;
341  #endif
342 
343  #if OGRE_WCHAR_T_STRINGS
344  typedef std::basic_stringstream<wchar_t,std::char_traits<wchar_t>,STLAllocator<wchar_t,GeneralAllocPolicy >> _StringStreamBase;
345  #else
346  typedef std::basic_stringstream<char,std::char_traits<char>,STLAllocator<char,GeneralAllocPolicy > > _StringStreamBase;
347  #endif
348 
349  #define StdStringT(T) std::basic_string<T, std::char_traits<T>, std::allocator<T> >
350  #define CustomMemoryStringT(T) std::basic_string<T, std::char_traits<T>, STLAllocator<T,GeneralAllocPolicy> >
351 
352  template<typename T>
353  bool operator <(const CustomMemoryStringT(T)& l,const StdStringT(T)& o)
354  {
355  return l.compare(0,l.length(),o.c_str(),o.length())<0;
356  }
357  template<typename T>
358  bool operator <(const StdStringT(T)& l,const CustomMemoryStringT(T)& o)
359  {
360  return l.compare(0,l.length(),o.c_str(),o.length())<0;
361  }
362  template<typename T>
363  bool operator <=(const CustomMemoryStringT(T)& l,const StdStringT(T)& o)
364  {
365  return l.compare(0,l.length(),o.c_str(),o.length())<=0;
366  }
367  template<typename T>
368  bool operator <=(const StdStringT(T)& l,const CustomMemoryStringT(T)& o)
369  {
370  return l.compare(0,l.length(),o.c_str(),o.length())<=0;
371  }
372  template<typename T>
373  bool operator >(const CustomMemoryStringT(T)& l,const StdStringT(T)& o)
374  {
375  return l.compare(0,l.length(),o.c_str(),o.length())>0;
376  }
377  template<typename T>
378  bool operator >(const StdStringT(T)& l,const CustomMemoryStringT(T)& o)
379  {
380  return l.compare(0,l.length(),o.c_str(),o.length())>0;
381  }
382  template<typename T>
383  bool operator >=(const CustomMemoryStringT(T)& l,const StdStringT(T)& o)
384  {
385  return l.compare(0,l.length(),o.c_str(),o.length())>=0;
386  }
387  template<typename T>
388  bool operator >=(const StdStringT(T)& l,const CustomMemoryStringT(T)& o)
389  {
390  return l.compare(0,l.length(),o.c_str(),o.length())>=0;
391  }
392 
393  template<typename T>
394  bool operator ==(const CustomMemoryStringT(T)& l,const StdStringT(T)& o)
395  {
396  return l.compare(0,l.length(),o.c_str(),o.length())==0;
397  }
398  template<typename T>
399  bool operator ==(const StdStringT(T)& l,const CustomMemoryStringT(T)& o)
400  {
401  return l.compare(0,l.length(),o.c_str(),o.length())==0;
402  }
403 
404  template<typename T>
405  bool operator !=(const CustomMemoryStringT(T)& l,const StdStringT(T)& o)
406  {
407  return l.compare(0,l.length(),o.c_str(),o.length())!=0;
408  }
409  template<typename T>
410  bool operator !=(const StdStringT(T)& l,const CustomMemoryStringT(T)& o)
411  {
412  return l.compare(0,l.length(),o.c_str(),o.length())!=0;
413  }
414 
415  template<typename T>
416  CustomMemoryStringT(T) operator +=(const CustomMemoryStringT(T)& l,const StdStringT(T)& o)
417  {
418  return CustomMemoryStringT(T)(l)+=o.c_str();
419  }
420  template<typename T>
421  CustomMemoryStringT(T) operator +=(const StdStringT(T)& l,const CustomMemoryStringT(T)& o)
422  {
423  return CustomMemoryStringT(T)(l.c_str())+=o.c_str();
424  }
425 
426  template<typename T>
427  CustomMemoryStringT(T) operator +(const CustomMemoryStringT(T)& l,const StdStringT(T)& o)
428  {
429  return CustomMemoryStringT(T)(l)+=o.c_str();
430  }
431 
432  template<typename T>
433  CustomMemoryStringT(T) operator +(const StdStringT(T)& l,const CustomMemoryStringT(T)& o)
434  {
435  return CustomMemoryStringT(T)(l.c_str())+=o.c_str();
436  }
437 
438  template<typename T>
439  CustomMemoryStringT(T) operator +(const T* l,const CustomMemoryStringT(T)& o)
440  {
441  return CustomMemoryStringT(T)(l)+=o;
442  }
443 
444  #undef StdStringT
445  #undef CustomMemoryStringT
446 
447 #else
448  #if OGRE_WCHAR_T_STRINGS
449  typedef std::wstring _StringBase;
450  #else
451  typedef std::string _StringBase;
452  #endif
453 
454  #if OGRE_WCHAR_T_STRINGS
455  typedef std::basic_stringstream<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> > _StringStreamBase;
456  #else
457  typedef std::basic_stringstream<char,std::char_traits<char>,std::allocator<char> > _StringStreamBase;
458  #endif
459 
460 #endif
461 
465 
466 }
467 
468 #if OGRE_STRING_USE_CUSTOM_MEMORY_ALLOCATOR
469 namespace std
470 {
471 #if (OGRE_COMPILER == OGRE_COMPILER_GNUC && OGRE_COMP_VER >= 430) || OGRE_COMPILER == OGRE_COMPILER_CLANG && !defined(STLPORT) && __cplusplus < 201103L
472  namespace tr1
473  {
474 #endif
475  template <> struct hash<Ogre::String>
476  {
477  public :
478  size_t operator()(const Ogre::String &str ) const
479  {
480  size_t _Val = 2166136261U;
481  size_t _First = 0;
482  size_t _Last = str.size();
483  size_t _Stride = 1 + _Last / 10;
484 
485  for(; _First < _Last; _First += _Stride)
486  _Val = 16777619U * _Val ^ (size_t)str[_First];
487  return (_Val);
488  }
489  };
490 #if (OGRE_COMPILER == OGRE_COMPILER_GNUC && OGRE_COMP_VER >= 430) || OGRE_COMPILER == OGRE_COMPILER_CLANG && !defined(STLPORT) && __cplusplus < 201103L
491  }
492 #endif
493 }
494 #endif
495 
496 //for stl container
497 namespace Ogre
498 {
499  template <typename T, typename A = STLAllocator<T, GeneralAllocPolicy> >
500  struct deque
501  {
502 #if OGRE_CONTAINERS_USE_CUSTOM_MEMORY_ALLOCATOR
503  typedef typename std::deque<T, A> type;
504  typedef typename std::deque<T, A>::iterator iterator;
505  typedef typename std::deque<T, A>::const_iterator const_iterator;
506 #else
507  typedef typename std::deque<T> type;
508  typedef typename std::deque<T>::iterator iterator;
509  typedef typename std::deque<T>::const_iterator const_iterator;
510 #endif
511  };
512 
513  template <typename T, typename A = STLAllocator<T, GeneralAllocPolicy> >
514  struct vector
515  {
516 #if OGRE_CONTAINERS_USE_CUSTOM_MEMORY_ALLOCATOR
517  typedef typename std::vector<T, A> type;
518  typedef typename std::vector<T, A>::iterator iterator;
519  typedef typename std::vector<T, A>::const_iterator const_iterator;
520 #else
521  typedef typename std::vector<T> type;
522  typedef typename std::vector<T>::iterator iterator;
523  typedef typename std::vector<T>::const_iterator const_iterator;
524 #endif
525  };
526 
527  template <typename T, typename A = STLAllocator<T, GeneralAllocPolicy> >
528  struct list
529  {
530 #if OGRE_CONTAINERS_USE_CUSTOM_MEMORY_ALLOCATOR
531  typedef typename std::list<T, A> type;
532  typedef typename std::list<T, A>::iterator iterator;
533  typedef typename std::list<T, A>::const_iterator const_iterator;
534 #else
535  typedef typename std::list<T> type;
536  typedef typename std::list<T>::iterator iterator;
537  typedef typename std::list<T>::const_iterator const_iterator;
538 #endif
539  };
540 
541  template <typename T, typename P = std::less<T>, typename A = STLAllocator<T, GeneralAllocPolicy> >
542  struct set
543  {
544 #if OGRE_CONTAINERS_USE_CUSTOM_MEMORY_ALLOCATOR
545  typedef typename std::set<T, P, A> type;
546  typedef typename std::set<T, P, A>::iterator iterator;
547  typedef typename std::set<T, P, A>::const_iterator const_iterator;
548 #else
549  typedef typename std::set<T, P> type;
550  typedef typename std::set<T, P>::iterator iterator;
551  typedef typename std::set<T, P>::const_iterator const_iterator;
552 #endif
553  };
554 
555  template <typename K, typename V, typename P = std::less<K>, typename A = STLAllocator<std::pair<const K, V>, GeneralAllocPolicy> >
556  struct map
557  {
558 #if OGRE_CONTAINERS_USE_CUSTOM_MEMORY_ALLOCATOR
559  typedef typename std::map<K, V, P, A> type;
560  typedef typename std::map<K, V, P, A>::iterator iterator;
561  typedef typename std::map<K, V, P, A>::const_iterator const_iterator;
562 #else
563  typedef typename std::map<K, V, P> type;
564  typedef typename std::map<K, V, P>::iterator iterator;
565  typedef typename std::map<K, V, P>::const_iterator const_iterator;
566 #endif
567  };
568 
569  template <typename K, typename V, typename P = std::less<K>, typename A = STLAllocator<std::pair<const K, V>, GeneralAllocPolicy> >
570  struct multimap
571  {
572 #if OGRE_CONTAINERS_USE_CUSTOM_MEMORY_ALLOCATOR
573  typedef typename std::multimap<K, V, P, A> type;
574  typedef typename std::multimap<K, V, P, A>::iterator iterator;
575  typedef typename std::multimap<K, V, P, A>::const_iterator const_iterator;
576 #else
577  typedef typename std::multimap<K, V, P> type;
578  typedef typename std::multimap<K, V, P>::iterator iterator;
579  typedef typename std::multimap<K, V, P>::const_iterator const_iterator;
580 #endif
581  };
582 
583 } // Ogre
584 
585 #endif // __OgrePrerequisites_H__
586 
587 

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 Wed Oct 16 2013 14:35:43