123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676 |
- //-----------------------------------------------------------------------------
- // Copyright (c) 2012 GarageGames, LLC
- //
- // Permission is hereby granted, free of charge, to any person obtaining a copy
- // of this software and associated documentation files (the "Software"), to
- // deal in the Software without restriction, including without limitation the
- // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- // sell copies of the Software, and to permit persons to whom the Software is
- // furnished to do so, subject to the following conditions:
- //
- // The above copyright notice and this permission notice shall be included in
- // all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
- // IN THE SOFTWARE.
- //-----------------------------------------------------------------------------
- #ifndef _ENGINEOBJECT_H_
- #define _ENGINEOBJECT_H_
- #ifndef _ENGINETYPES_H_
- #include "console/engineTypes.h"
- #endif
- #ifndef _REFBASE_H_
- #include "core/util/refBase.h"
- #endif
- /// Disable TMM for this file.
- #include "platform/tmm_off.h"
- /// @file
- /// This file contains the framework for defining class types for interfacing
- /// through engine API.
- class EngineObject;
- /// Assign the current class and all its subclasses to the given export scope.
- /// May be overridden by subclasses.
- ///
- /// @code
- /// class MyClass : public EngineObject
- /// {
- /// DECLARE_CLASS( MyClass, EngineObject );
- /// DECLARE_INSCOPE( MyAPI );
- /// };
- /// @endcode
- #define DECLARE_INSCOPE( name ) \
- typedef name __DeclScope;
-
- /// Declare that this class and all its subclasses cannot be instantiated through
- /// the API, i.e. objects of these classes can only be created inside the engine.
- ///
- /// @code
- /// class MyClass : public EngineObject
- /// {
- /// DECLARE_CLASS( MyClass, EngineObject );
- /// DECLARE_NONINSTANTIABLE;
- /// };
- /// @endcode
- #define DECLARE_NONINSTANTIABLE \
- typedef ::FalseType __IsInstantiableType;
-
- /// Declare that this class and all its subclasses can be instantiated through the
- /// API using their respective create() functions.
- ///
- /// May be overridden by subclasses.
- ///
- /// @code
- /// class MyClass : public EngineObject
- /// {
- /// DECLARE_CLASS( MyClass, EngineObject );
- /// DECLARE_INSTANTIABLE;
- /// };
- /// @endcode
- #define DECLARE_INSTANTIABLE \
- typedef ::TrueType __IsInstantiableType;
- /// Declare a class for which the object's may be forcefully disposed of by the engine.
- /// In essense, this means that such objects can only be weak-referenced from within the
- /// control layer as their lifetime is ultimately controlled by the engine. This is
- /// used for all resource type objects that are owned by their devices.
- ///
- /// An alternative to disposable types would be to shield the control layer from direct
- /// access to these objects and rather expose only intermediary objects. However, at some
- /// point this just gets crazy. The control layer wraps around engine objects that wrap
- /// around internal objects. The internal object goes away, invalidates the native wrapper
- /// which invalidates the managed wrapper.
- ///
- /// By exposing the control layer directly to in-engine resources using disposable objects,
- /// intermediary steps and code are made unnecessary while the control layer is still made
- /// aware of the fact that ownership of these objects ultimately and firmly belongs with
- /// the engine.
- ///
- /// One important guarantee for disposable types is that an object will <em>not</em> go
- /// away <em>unless</em> the control layer calls into the engine. This means that these
- /// objects will not magically disappear while managed code is running.
- ///
- /// @note This macro automatically redefines destroySelf().
- /// @warn Reference-counting is still used for disposable types!! This means that if the
- /// reference-count drops to zero, the object will be deleted as any other object.
- ///
- /// @see IMPLEMENT_DISPOSABLE
- #define DECLARE_DISPOSABLE \
- protected: \
- typedef ::TrueType __IsDisposableType; \
- DECLARE_CALLBACK( void, onDispose, () ); \
- public: \
- virtual void destroySelf() \
- { \
- onDispose_callback(); \
- SuperType::destroySelf(); \
- }
- /// Matching implement for DECLARE_DISPOSABLE.
- ///
- /// @param type The disposable C++ class type.
- #define IMPLEMENT_DISPOSABLE( type ) \
- IMPLEMENT_NEW_CALLBACK( type, onDispose, void, (), (), \
- "Called before the instance is disposed." );
-
- /// Declare that the current class (and any of its descendents) can only have a single instance.
- ///
- /// @code
- /// class MySingletonClass : public EngineObject
- /// {
- /// DECLARE_CLASS( MySingletonClass, EngineObject );
- /// DECLARE_SINGLETON;
- /// };
- /// @endcode
- ///
- /// @note At the moment, DECLARE_SINGLETON disallows the use of custom create methods
- /// on the same class.
- #define DECLARE_SINGLETON \
- private: \
- static ThisType* _smInstance; \
- struct _clearInstance; \
- friend struct _clearInstance; \
- struct _clearInstance { \
- ~_clearInstance() { _smInstance = NULL; } \
- } _clearInstanceInst; \
- public: \
- static ThisType* createSingleton(); \
- static void destroySingleton(); \
- protected: \
- typedef ::TrueType __IsSingletonType; \
- DEFINE_CREATE_METHOD \
- { \
- return createSingleton(); \
- } \
- public: \
- static ThisType* instance() \
- { \
- return _smInstance; \
- }
- /// Matching implement for DECLARE_SINGLETON.
- /// @param type The C++ class type.
- #define IMPLEMENT_SINGLETON( type ) \
- type::ThisType* type::_smInstance; \
- type::ThisType* type::createSingleton() \
- { \
- if( _smInstance != NULL ) \
- { \
- Con::errorf( "%s::create - Singleton instance already created", \
- TYPE< ThisType >()->getFullyQualifiedExportName().c_str() ); \
- return NULL; \
- } \
- _smInstance = new ThisType(); \
- _smInstance->incRefCount(); \
- return _smInstance; \
- } \
- void type::destroySingleton() \
- { \
- if( !_smInstance ) \
- return; \
- if( ::IsTrueType< __IsDisposableType >() ) \
- _smInstance->destroySelf(); \
- else \
- _smInstance->decRefCount(); \
- } \
- DefineNewEngineStaticMethod( type, getInstance, type*, (),, \
- "Get the singleton " #type " instance.\n\n" \
- "@return The " #type " singleton." ) \
- { \
- return type::instance(); \
- }
- /// Declare a static class, i.e. a class which only acts as an export scope. Static
- /// classes cannot be instantiated, neither through the API nor inside the engine (at
- /// least in a form that would be usable within the API).
- ///
- /// @code
- /// class MyFunctions
- /// {
- /// DECLARE_STATIC_CLASS( MyFunctions );
- /// };
- ///
- /// IMPLEMENT_STATIC_CLASS( MyFunctions,, "doc" );
- ///
- /// DefineStaticEngineMethod( MyFunctions, doSomething, void, (),, "" )
- /// {
- /// // ...
- /// }
- /// @endcode
- ///
- /// @param type The C++ class type.
- ///
- /// @see IMPLEMENT_STATIC_CLASS
- #define DECLARE_STATIC_CLASS( type ) \
- private: \
- static EngineExportScope __engineExportScopeInst; \
- static EngineExportScope& __engineExportScope() \
- { return __engineExportScopeInst; } \
- public: \
- template< typename T > friend struct ::_SCOPE; \
-
- /// Matching implement for DECLARE_STATIC_CLASS.
- ///
- /// @param type The C++ type of the static class. Also used as export name.
- /// @param scope Export scope to place the static class in.
- /// @param doc Documentation string.
- #define IMPLEMENT_STATIC_CLASS( type, scope, doc ) \
- EngineExportScope type::__engineExportScopeInst( #type, &_SCOPE< scope >()(), doc );
- /// Declare a concrete class @a type derived from the class @a super. Whether the
- /// class can be instantiated by the control layer depends on its instantiability.
- ///
- /// @code
- /// class MyClass : public EngineObject
- /// {
- /// DECLARE_CLASS( MyClass, EngineObject );
- /// };
- /// @endcode
- ///
- /// @param type C++ class type.
- /// @param super C++ class type of the superclass. May be void only for EngineObject.
- ///
- /// @see IMPLEMENT_CLASS
- /// @see IMPLEMENT_NONINSTANTIABLE_CLASS
- #define DECLARE_CLASS( type, super ) \
- public: \
- typedef type ThisType; \
- typedef super SuperType; \
- template< typename T > friend struct ::_EngineTypeTraits; \
- template< typename T > friend struct ::_SCOPE; \
- template< typename T > friend T* _CREATE(); \
- template< typename T, typename Base > friend class ::EngineClassTypeInfo; \
- private: \
- typedef ::_Private::_ConcreteClassBase< ThisType > _ClassBase; \
- static EngineClassTypeInfo< ThisType, _ClassBase > _smTypeInfo; \
- static EngineExportScope& __engineExportScope(); \
- static EnginePropertyTable& _smPropertyTable; \
- virtual const EngineTypeInfo* __typeinfo() const; \
- public:
-
- /// Declare an abstract class @a type derived from the class @a super.
- ///
- /// @code
- /// class MyClass : public EngineObject
- /// {
- /// DECLARE_ABSTRACT_CLASS( MyClass, EngineObject );
- /// };
- /// @endcode
- ///
- /// @param type C++ class type.
- /// @param super C++ class type of the superclass. May be void only for EngineObject.
- ///
- /// @see IMPLEMENT_NONINSTANTIABLE_CLASS
- #define DECLARE_ABSTRACT_CLASS( type, super ) \
- public: \
- typedef type ThisType; \
- typedef super SuperType; \
- template< typename T > friend struct ::_EngineTypeTraits; \
- template< typename T > friend struct ::_SCOPE; \
- template< typename T > friend T* _CREATE(); \
- template< typename T, typename Base > friend class ::EngineClassTypeInfo; \
- private: \
- typedef ::_Private::_AbstractClassBase< ThisType > _ClassBase; \
- static EngineClassTypeInfo< ThisType, _ClassBase > _smTypeInfo; \
- static EngineExportScope& __engineExportScope(); \
- static EnginePropertyTable& _smPropertyTable; \
- virtual const EngineTypeInfo* __typeinfo() const; \
- public:
- /// Matching implement for DECLARE_ABSTRACT_CLASS or DECLARE_CLASS for classes
- /// that are not instantiable through the API.
- ///
- /// @code
- /// class MyClass : public EngineObject
- /// {
- /// DECLARE_CLASS( MyClass, EngineObject );
- /// DECLARE_INSCOPE( MyScope );
- /// DECLARE_NONINSTANTIABLE;
- /// };
- ///
- /// IMPLEMENT_NONINSTANTIABLE_CLASS( MyClass, "My class." )
- /// PROPERTY( myProperty, 1, "My property.", EnginePropertyTransient )
- /// END_IMPLEMENT_CLASS;
- /// @endcode
- ///
- /// @note If you want the export name to be different to the actual class
- /// name, use a typedef.
- ///
- /// @param type The C++ class type.
- /// @doc Documentation string.
- #define IMPLEMENT_NONINSTANTIABLE_CLASS( type, doc ) \
- DEFINE_CALLIN( fn ## type ## _staticGetType, staticGetType, type, const EngineTypeInfo*, (),,, \
- "Get the type info object for the " #type " class.\n\n" \
- "@return The type info object for " #type ) \
- { \
- return ::TYPE< type >(); \
- } \
- EngineClassTypeInfo< type::ThisType, type::_ClassBase > \
- type::_smTypeInfo( #type, &_SCOPE< __DeclScope >()(), doc ); \
- EngineExportScope& type::__engineExportScope() { return type::_smTypeInfo; } \
- const EngineTypeInfo* type::__typeinfo() const { return &_smTypeInfo; } \
- namespace { namespace _ ## type { \
- extern EnginePropertyTable _propertyTable; \
- } } \
- EnginePropertyTable& type::_smPropertyTable = _ ## type::_propertyTable; \
- namespace { namespace _ ## type { \
- EnginePropertyTable::Property _properties[] = {
- /// Matching implement to DECLARE_CLASS for classes that are instantiable
- /// through the API.
- ///
- /// @note engineFunctions.h must be included for this macro to work.
- ///
- /// @param type The C++ class type.
- /// @param doc Documentation string.
- #define IMPLEMENT_CLASS( type, doc ) \
- DEFINE_CALLIN( fn ## type ## _create, create, type, type*, (),,, \
- "Create a new " #type " instance.\n" \
- "@return A new " #type " instance with a reference count of 1." ) \
- { \
- return ::_CREATE< type >(); \
- } \
- IMPLEMENT_NONINSTANTIABLE_CLASS( type, doc )
-
- /// Close an IMPLEMENT_CLASS or IMPLEMENT_NONINSTANTIABLE_CLASS block.
- #define END_IMPLEMENT_CLASS \
- { NULL } \
- }; \
- EnginePropertyTable _propertyTable \
- ( sizeof( _properties ) / sizeof( _properties[ 0 ] ) - 1, _properties ); \
- } }
-
- /// Define a property on the current class.
- ///
- /// A property named XXX must have a corresponding "getXXX" and/or "setXXX" accessor
- /// method defined on the class. If there is only a "setXXX" method, the property is
- /// write-only. If there is only a "getXXX", the property is read-only. If both are
- /// defined, the property is read-write.
- ///
- /// If the accessors are static methods, the property is a static property. Otherwise
- /// it is an instance property.
- ///
- /// The type of the property is determined by its accessor methods.
- ///
- /// A getXXX method must take no arguments and return a value. A setXXX method must take
- /// one argument and return void.
- ///
- /// If the property is indexed (@a numElements != 1), the get and set methods take an
- /// additional first argument which is the integer index (type S32). Additionally, the get method
- /// must be called "getXXXElement" and the set method must be called "setXXXElement".
- ///
- /// Indexed properties may be either fixed-size or variable-sized. Fixed-size indexed
- /// properties have numElements count > 1. Variable-size indexed properties have a
- /// numElements count of 0. Variable-sized indexed properties must have an additional
- /// method "getXXXCount" that returns the current count of elements for the given property.
- ///
- /// @code
- /// IMPLEMENT_CLASS( MyClass, "My class." )
- /// PROPERTY( myProperty, 1, "My property.", EnginePropertyTransient )
- /// END_IMPLEMENT_CLASS;
- /// @endcode
- ///
- /// @note Case is ignored when matching get and set methods to property definitions.
- ///
- /// @param name The name of the property. Must correspond with the get and/or set methods.
- /// @param numElements If this is a fixed size array property, this is the number of elements
- /// the fixed array has. Otherwise 1.
- /// @param doc Documentation string.
- /// @param flags A combination of EnginePropertyFlags or simply 0 if not applicable.
- ///
- /// @see EnginePropertyFlags
- #define PROPERTY( name, numElements, doc, flags ) \
- { #name, doc, numElements, flags },
-
- ///
- #define PROPERTY_GROUP( name, numElements, doc ) \
- { #name, doc, numElements, EnginePropertyGroupBegin },
- ///
- #define END_PROPERTY_GROUP \
- { NULL, NULL, 0, EnginePropertyGroupEnd },
- /// Define a custom create function for this class and its subclasses. Create
- /// functions are used to create new instances of class types. This code will be
- /// called by the automatically generated "createXXX" functions exported through
- /// the API.
- ///
- /// The type of class being created is available to the code as the type parameter "T"
- /// which is guaranteed to be a subtype of the current class type.
- ///
- /// @code
- /// class MyClass : public EngineObject
- /// {
- /// DECLARE_CLASS( MyClass, EngineObject );
- /// protected:
- /// DEFINE_CREATE_METHOD
- /// {
- /// T* object = new T();
- /// object->incRefCount();
- /// object->_registerObject();
- /// return object;
- /// }
- /// virtual void _registerObject();
- /// };
- /// @endcode
- ///
- /// @note A create method must return an object with a reference count of 1.
- #define DEFINE_CREATE_METHOD \
- template< typename T > \
- static T* __create()
- /// Define a method that calls back into the control layer.
- ///
- /// @see IMPLEMENT_CALLBACK
- #define DECLARE_CALLBACK( returnType, name, args ) \
- virtual returnType name ## _callback args
- // Our backdoor into calling the __create method on any class even if it is
- // protected or private. This function is automatically made friends of any
- // EngineObject class. Should be used except by internal API code.
- template< typename T >
- inline T* _CREATE()
- {
- return T::template __create< T >();
- }
- /// Interface for object memory allocation.
- class IEngineObjectPool
- {
- public:
-
- /// Allocate a new object memory block of the given size.
- /// @return Pointer to a new memory block or NULL on failure.
- virtual void* allocateObject( U32 size TORQUE_TMM_ARGS_DECL ) = 0;
-
- /// Return the member for the object at the given address to the
- /// allocator for reuse.
- /// @param ptr Pointer to an object memory block previously allocated with allocateObject().
- virtual void freeObject( void* ptr ) = 0;
-
- /// Instance of the object pool to use by default.
- static IEngineObjectPool* DEFAULT;
- };
- /// Singleton class that uses the C runtime memory routines for allocating objects.
- class EngineCRuntimeObjectPool : public IEngineObjectPool
- {
- public:
-
- typedef IEngineObjectPool Parent;
-
- protected:
-
- static EngineCRuntimeObjectPool smInstance;
-
- public:
- /// Return the singleton instance of this pool.
- static EngineCRuntimeObjectPool* instance() { return &smInstance; }
-
- // IEngineObjectPool
- virtual void* allocateObject( U32 size TORQUE_TMM_ARGS_DECL );
- virtual void freeObject( void* ptr );
- };
- /// Base class for all objects that may be passed to the control layer.
- ///
- /// A set of rules applies to all EngineObject-derived classes:
- ///
- /// - Every EngineObject class must have a default constructor.
- /// - The default constructor and the destructor of every EngineObject class must be public.
- /// - If an EngineObject class inherits from multiple classes, the class leading back to EngineObject
- /// must be the @b first class in the list to ensure binary-compatible class layouts.
- /// - EngineObjects are cooperatively reference-counted by both the engine as well as the control
- /// layer.
- class EngineObject : public StrongRefBase
- {
- public:
-
- DECLARE_ABSTRACT_CLASS( EngineObject, void );
- DECLARE_INSCOPE( _GLOBALSCOPE );
- DECLARE_INSTANTIABLE;
-
- friend const EngineTypeInfo* TYPEOF( const EngineObject* ); // __typeinfo
- friend void*& _USERDATA( EngineObject* ); // mEngineObjectUserData
- friend class StaticEngineObject; // mEngineObjectPool
-
- protected:
-
- typedef ::FalseType __IsDisposableType;
- typedef ::FalseType __IsSingletonType;
- DEFINE_CREATE_METHOD
- {
- T* object = new T;
- object->incRefCount();
- return object;
- }
- /// Subclasses should overload this method instead of the public destroySelf().
- virtual void _destroySelf() {}
-
- ///
- static void* _allocateObject( size_t size, IEngineObjectPool* pool TORQUE_TMM_ARGS_DECL );
-
- public:
-
- EngineObject();
- virtual ~EngineObject();
- /// Return a string that describes this instance. Meant primarily for debugging.
- virtual String describeSelf() const;
-
- #ifndef TORQUE_DISABLE_MEMORY_MANAGER
- // Make sure no matter what, we get the new/delete calls.
- void* operator new( size_t size );
- void* operator new( size_t size, IEngineObjectPool* pool );
- #endif
-
- /// Allocate a new object in the default object pool.
- /// @param size Size of the object in bytes.
- /// @return Memory block for new object; never NULL.
- void* operator new( size_t size TORQUE_TMM_ARGS_DECL );
-
- /// Allocate a new object in the given object pool.
- ///
- /// If the given pool's allocateObject returns NULL, the method will fall back
- /// to the default pool.
- ///
- /// @param size Size of the object in bytes.
- /// @param pool Object pool to allocate the object in.
- /// @return Memory block for the new object; never NULL.
- void* operator new( size_t size, IEngineObjectPool* pool TORQUE_TMM_ARGS_DECL );
-
- /// Placement new.
- void* operator new( size_t size, void* ptr ) { return ptr; }
-
- /// Release the given object's memory in the pool it has been allocated from.
- void operator delete( void* ptr );
- /// Return the pool of EngineObjects to which this object belongs.
- IEngineObjectPool* getEngineObjectPool() const { return mEngineObjectPool; }
-
- // StrongRefBase
- virtual void destroySelf();
-
- #ifdef TORQUE_DEBUG
-
- /// @name Instance Tracking (debugging only)
- ///
- /// In debug builds, all EngineObjects are kept on a global list so that it is easy
- /// to enumerate all live objects at any time.
- ///
- /// @note This is @b NOT thread-safe.
- /// @{
-
- /// Type of callback function for iterating over EngineObject instances.
- typedef void ( *DebugEnumInstancesCallback )( EngineObject* );
- /// Dump describeSelf()s of all live ConsoleObjects to the console.
- static void debugDumpInstances();
- /// Call the given callback for all instances of the given type.
- /// Callback may also be NULL in which case the method just iterates
- /// over all instances of the given type. This is useful for setting
- /// a breakpoint during debugging.
- static void debugEnumInstances( const std::type_info& type, DebugEnumInstancesCallback callback );
-
- /// Same as above but uses an export class name and also includes
- /// inheritance (i.e. enumerates all instances of the given class and
- /// its subclasses).
- static void debugEnumInstances( const char* className, DebugEnumInstancesCallback callback );
- private:
-
- /// Next object in global link chain of engine objects.
- /// @note Debug builds only.
- EngineObject* mNextEngineObject;
-
- /// Previous object in global link chain of engine objects.
- /// @note Debug builds only.
- EngineObject* mPrevEngineObject;
- /// Total number of engine objects currently instantiated.
- /// @note Debug builds only.
- static U32 smNumEngineObjects;
-
- /// First object in the global link chain of engine objects.
- /// @note Debug builds only.
- static EngineObject* smFirstEngineObject;
-
- /// @}
-
- #endif
- private:
-
- /// Object pool to which this object belongs. If this is NULL,
- /// the object will not deallocate itself when it is destructed.
- /// This is useful for inline allocation of objects.
- IEngineObjectPool* mEngineObjectPool;
-
- /// Opaque user data pointer that the control layer may install
- /// on any engine object. Most importantly, this allows control layers
- /// to very easily keep track of EngineObjects that they have already
- /// created their own wrapper objects for.
- void* mEngineObjectUserData;
- // Disable array new/delete operators.
- void* operator new[]( size_t );
- void operator delete[]( void* );
- };
- /// A statically allocated engine object.
- ///
- /// Static objects have an implicit initial reference count of one and will not
- /// delete themselves even when asked to do so.
- class StaticEngineObject : public EngineObject
- {
- public:
- DECLARE_ABSTRACT_CLASS( StaticEngineObject, EngineObject );
- DECLARE_NONINSTANTIABLE;
-
- StaticEngineObject();
-
- // EngineObject.
- virtual void destroySelf();
- };
- typedef StrongRefPtr< EngineObject > EngineObjectRef;
- typedef WeakRefPtr< EngineObject > EngineObjectWeakRef;
- /// Return the type info object for the dynamic type of the given object.
- /// @param object An EngineObject or NULL.
- /// @return An EngineTypeInfo instance or NULL if @a object is NULL.
- inline const EngineTypeInfo* TYPEOF( const EngineObject* object )
- {
- if( !object )
- return NULL;
- return object->__typeinfo();
- }
- #include "platform/tmm_on.h"
- #endif // !_ENGINEOBJECT_H_
|