ponder 3.1
C++ reflection library
pondertype.hpp File Reference
#include <ponder/config.hpp>
#include "type.hpp"

Namespaces

 ponder
 Root namespace that encapsulates all of Ponder.
 

Macros

#define PONDER_TYPE(...)
 Macro used to register a C++ type to Ponder. More...
 
#define PONDER_AUTO_TYPE(TYPE, REGISTER_FN)
 Macro used to register a C++ type to Ponder with automatic, on-demand metaclass creation. More...
 
#define PONDER_TYPE_NONCOPYABLE(TYPE)
 Macro used to register a non-copyable C++ type to Ponder. More...
 
#define PONDER_AUTO_TYPE_NONCOPYABLE(TYPE, REGISTER_FN)
 Macro used to register a non-copyable C++ type to Ponder with automatic metaclass creation. More...
 
#define PONDER_POLYMORPHIC()
 Macro used to activate the Ponder RTTI system into a hierarchy of classes. More...
 

Macro Definition Documentation

◆ PONDER_AUTO_TYPE

#define PONDER_AUTO_TYPE (   TYPE,
  REGISTER_FN 
)
Value:
namespace ponder { namespace detail { \
template<> struct StaticTypeDecl<TYPE> { \
static TypeId id(bool checkRegister = true) { \
if (checkRegister) detail::ensureTypeRegistered(calcTypeId<TYPE>(), REGISTER_FN); \
return calcTypeId<TYPE>(); \
} \
static const char* name(bool checkRegister = true) { \
if (checkRegister) detail::ensureTypeRegistered(calcTypeId<TYPE>(), REGISTER_FN); \
return #TYPE; \
} \
static constexpr bool defined = true, copyable = true; \
}; \
}}
Root namespace that encapsulates all of Ponder.
Definition: args.hpp:38

Macro used to register a C++ type to Ponder with automatic, on-demand metaclass creation.

Using this macro rather than PONDER_TYPE() will make Ponder automatically call the provided registration function the first time the metaclass is requested. This is useful when you don't want to have to manually call an "init" function to create your metaclass.

Every type manipulated by Ponder must be registered with PONDER_TYPE(), PONDER_AUTO_TYPE() or their NONCOPYABLE versions.

Note
This macro will fail with types that contain commas, e.g. Data<float,int,int>. Instead, use PONDER_TYPE().

Example:

class MyClass
{
public:
static void registerMetaClass();
};
PONDER_AUTO_TYPE(MyClass, &MyClass::registerMetaClass)
void MyClass::registerMetaClass()
{
ponder::Class::declare<MyClass>("MyClass")
// ... declarations ... ;
}
See also
PONDER_TYPE(), Declaration Example, Shapes Example

◆ PONDER_AUTO_TYPE_NONCOPYABLE

#define PONDER_AUTO_TYPE_NONCOPYABLE (   TYPE,
  REGISTER_FN 
)
Value:
namespace ponder { namespace detail { \
template <> struct StaticTypeDecl<TYPE> { \
static TypeId id(bool checkRegister = true) { \
if (checkRegister) detail::ensureTypeRegistered(calcTypeId<TYPE>(), REGISTER_FN); \
return calcTypeId<TYPE>(); \
} \
static const char* name(bool checkRegister = true) { \
if (checkRegister) detail::ensureTypeRegistered(calcTypeId<TYPE>(), REGISTER_FN); \
return #TYPE; \
} \
static constexpr bool defined = true, copyable = true; \
}; \
}}
Root namespace that encapsulates all of Ponder.
Definition: args.hpp:38

Macro used to register a non-copyable C++ type to Ponder with automatic metaclass creation.

Using this macro rather than PONDER_TYPE_NONCOPYABLE will make Ponder automatically call the provided registration function the first time the metaclass is requested. This is useful when you don't want to have to manually call an "init" function to create your metaclass.

Every type manipulated by Ponder must be registered with PONDER_TYPE(), PONDER_AUTO_TYPE() or their NONCOPYABLE versions.

See also
PONDER_AUTO_TYPE(), PONDER_TYPE_NONCOPYABLE()

◆ PONDER_POLYMORPHIC

#define PONDER_POLYMORPHIC ( )
Value:
public: \
virtual ponder::TypeId ponderClassId() const {return ponder::detail::staticTypeId(*this);} \
private:

Macro used to activate the Ponder RTTI system into a hierarchy of classes.

This macro must be inserted in both base and derived classes if you want Ponder to be able to retrieve the dynamic type of polymorphic objects.

Note
This macro does not need to be inserted into all Ponder classes being declared, only ones which would like to support features like downcasting via polymorphism. See Shapes Example for an example.

Example:

class MyBase
{
};
class MyDerived : public MyBase
{
};
MyBase* b = new MyDerived;
const ponder::Class& mc = ponder::classByObject(b);
// mc == metaclass of MyDerived
See also
Shapes Example

◆ PONDER_TYPE

#define PONDER_TYPE (   ...)
Value:
namespace ponder { namespace detail { \
template<> struct StaticTypeDecl<__VA_ARGS__> \
{ \
static TypeId id(bool = true) {return calcTypeId<__VA_ARGS__>();} \
static constexpr const char* name(bool = true) {return #__VA_ARGS__;} \
static constexpr bool defined = true, copyable = true; \
}; \
}}
Root namespace that encapsulates all of Ponder.
Definition: args.hpp:38

Macro used to register a C++ type to Ponder.

Every type manipulated by Ponder must be registered with PONDER_TYPE(), PONDER_AUTO_TYPE() or their NONCOPYABLE versions.

Example:

class MyClass
{
class MyNestedClass
{
};
};
PONDER_TYPE(MyClass)
PONDER_TYPE(MyClass::MyNestedClass)
Note
This macro handles types that contain commas, e.g. Data<float,int,int>.
See also
PONDER_TYPE(), PONDER_AUTO_TYPE(), Declaration Example

◆ PONDER_TYPE_NONCOPYABLE

#define PONDER_TYPE_NONCOPYABLE (   TYPE)
Value:
namespace ponder { namespace detail { \
template <> struct StaticTypeDecl<TYPE> { \
static const char* name(bool = true) {return #TYPE;} \
static constexpr bool defined = true, copyable = true; \
}; \
}}
Root namespace that encapsulates all of Ponder.
Definition: args.hpp:38

Macro used to register a non-copyable C++ type to Ponder.

Disabled copy and assignment cannot be detected at compile-time, thus users have to explicitly tell Ponder when a type is not copyable/assignable. Objects of a non-copyable class can be modified through their metaproperties, but they can't be written with a single call to replace to whole object.

Every type manipulated by Ponder must be registered with PONDER_TYPE(), PONDER_AUTO_TYPE() or their NONCOPYABLE versions.

Example:

class NonCopyable : util::NonCopyable
{
int x;
};
class MyClass
{
NonCopyable* nc;
};
PONDER_TYPE(MyClass)
MyClass c;
const ponder::Class& m1 = ponder::classByObject(c);
const ponder::Class& m2 = ponder::classByObject(c.nc);
const ponder::Property& p1 = m1.property("nc");
const ponder::Property& p2 = m2.property("x");
p1.set(c, NonCopyable()); // ERROR
p2.set(p1.get(c).to<ponder::UserObject>(), 10); // OK
See also
PONDER_TYPE()