Merge pull request #1535 from GarageGames/AbstractConObjects

[CLONE] Add support for abstract ConObjects
This commit is contained in:
Anis 2016-02-27 02:38:39 +01:00
commit fa5a6f3eae
2 changed files with 154 additions and 116 deletions

View file

@ -567,14 +567,35 @@ extern AbstractClassRep::FieldList sg_tempFieldList;
/// @see AbtractClassRep /// @see AbtractClassRep
/// @see ConsoleObject /// @see ConsoleObject
template< class T > template< class T >
class ConcreteClassRep : public AbstractClassRep class ConcreteAbstractClassRep : public AbstractClassRep
{ {
public: public:
virtual AbstractClassRep* getContainerChildClass(const bool recurse)
{
// Fetch container children type.
AbstractClassRep* pChildren = T::getContainerChildStaticClassRep();
if (!recurse || pChildren != NULL)
return pChildren;
// Fetch parent type.
AbstractClassRep* pParent = T::getParentStaticClassRep();
if (pParent == NULL)
return NULL;
// Get parent container children.
return pParent->getContainerChildClass(recurse);
}
virtual WriteCustomTamlSchema getCustomTamlSchema(void)
{
return T::getStaticWriteCustomTamlSchema();
}
static EnginePropertyTable _smPropertyTable; static EnginePropertyTable _smPropertyTable;
static EnginePropertyTable& smPropertyTable; static EnginePropertyTable& smPropertyTable;
ConcreteClassRep( const char* name, ConcreteAbstractClassRep(const char* name,
const char* conTypeName, const char* conTypeName,
S32* conTypeIdPtr, S32* conTypeIdPtr,
S32 netClassGroupMask, S32 netClassGroupMask,
@ -609,26 +630,8 @@ class ConcreteClassRep : public AbstractClassRep
registerClassRep(this); registerClassRep(this);
}; };
virtual AbstractClassRep* getContainerChildClass(const bool recurse) /// Wrap constructor.
{ ConsoleObject* create() const { return NULL; }
// Fetch container children type.
AbstractClassRep* pChildren = T::getContainerChildStaticClassRep();
if (!recurse || pChildren != NULL)
return pChildren;
// Fetch parent type.
AbstractClassRep* pParent = T::getParentStaticClassRep();
if (pParent == NULL)
return NULL;
// Get parent container children.
return pParent->getContainerChildClass(recurse);
}
virtual WriteCustomTamlSchema getCustomTamlSchema(void)
{
return T::getStaticWriteCustomTamlSchema();
}
/// Perform class specific initialization tasks. /// Perform class specific initialization tasks.
/// ///
@ -651,9 +654,6 @@ class ConcreteClassRep : public AbstractClassRep
AbstractClassRep::init(); AbstractClassRep::init();
} }
/// Wrap constructor.
ConsoleObject* create() const { return new T; }
/// @name Console Type Interface /// @name Console Type Interface
/// @{ /// @{
@ -680,9 +680,28 @@ class ConcreteClassRep : public AbstractClassRep
/// @} /// @}
}; };
template< typename T > EnginePropertyTable ConcreteClassRep< T >::_smPropertyTable( 0, NULL ); template< class T >
template< typename T > EnginePropertyTable& ConcreteClassRep< T >::smPropertyTable = ConcreteClassRep< T >::_smPropertyTable; class ConcreteClassRep : public ConcreteAbstractClassRep<T>
{
public:
ConcreteClassRep(const char* name,
const char* conTypeName,
S32* conTypeIdPtr,
S32 netClassGroupMask,
S32 netClassType,
S32 netEventDir,
AbstractClassRep* parent,
const char* (*parentDesc)())
: ConcreteAbstractClassRep<T>(name, conTypeName, conTypeIdPtr, netClassGroupMask, netClassType, netEventDir, parent, parentDesc)
{
}
/// Wrap constructor.
ConsoleObject* create() const { return new T; }
};
template< typename T > EnginePropertyTable ConcreteAbstractClassRep< T >::_smPropertyTable(0, NULL);
template< typename T > EnginePropertyTable& ConcreteAbstractClassRep< T >::smPropertyTable = ConcreteAbstractClassRep< T >::_smPropertyTable;
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Forward declaration of this function so it can be used in the class // Forward declaration of this function so it can be used in the class
@ -763,6 +782,15 @@ public:
/// Gets the ClassRep. /// Gets the ClassRep.
virtual AbstractClassRep* getClassRep() const; virtual AbstractClassRep* getClassRep() const;
#define DECLARE_ABSTRACT_CONOBJECT( className ) \
DECLARE_ABSTRACT_CLASS( className, Parent ); \
static S32 _smTypeId; \
static ConcreteAbstractClassRep< className > dynClassRep; \
static AbstractClassRep* getParentStaticClassRep(); \
static AbstractClassRep* getStaticClassRep(); \
static SimObjectRefConsoleBaseType< className > ptrRefType; \
virtual AbstractClassRep* getClassRep() const
/// Set the value of a field. /// Set the value of a field.
bool setField(const char *fieldName, const char *value); bool setField(const char *fieldName, const char *value);
@ -1172,6 +1200,16 @@ inline bool& ConsoleObject::getDynamicGroupExpand()
AbstractClassRep::WriteCustomTamlSchema className::getStaticWriteCustomTamlSchema() { return schema; } \ AbstractClassRep::WriteCustomTamlSchema className::getStaticWriteCustomTamlSchema() { return schema; } \
ConcreteClassRep<className> className::dynClassRep( #className, "Type" #className, &_smTypeId, 0, -1, 0, className::getParentStaticClassRep(), &Parent::__description ) ConcreteClassRep<className> className::dynClassRep( #className, "Type" #className, &_smTypeId, 0, -1, 0, className::getParentStaticClassRep(), &Parent::__description )
#define IMPLEMENT_ABSTRACT_CONOBJECT( className ) \
IMPLEMENT_NONINSTANTIABLE_CLASS( className, NULL ) \
END_IMPLEMENT_CLASS; \
S32 className::_smTypeId; \
SimObjectRefConsoleBaseType< className > className::ptrRefType( "Type" #className "Ref" ); \
AbstractClassRep* className::getClassRep() const { return &className::dynClassRep; } \
AbstractClassRep* className::getStaticClassRep() { return &dynClassRep; } \
AbstractClassRep* className::getParentStaticClassRep() { return Parent::getStaticClassRep(); } \
ConcreteAbstractClassRep<className> className::dynClassRep( #className, "Type" #className, &_smTypeId, 0, -1, 0, className::getParentStaticClassRep(), &Parent::__description )
#define IMPLEMENT_CO_NETOBJECT_V1( className ) \ #define IMPLEMENT_CO_NETOBJECT_V1( className ) \
IMPLEMENT_CLASS( className, NULL ) \ IMPLEMENT_CLASS( className, NULL ) \
END_IMPLEMENT_CLASS; \ END_IMPLEMENT_CLASS; \

View file

@ -362,7 +362,7 @@ class EngineTypeInfo : public EngineExportScope
// them to retroactively install property tables. Will be removed // them to retroactively install property tables. Will be removed
// when the console interop is removed and all classes are migrated // when the console interop is removed and all classes are migrated
// to the new system. // to the new system.
template< typename T > friend class ConcreteClassRep; template< typename T > friend class ConcreteAbstractClassRep;
protected: protected: