DynaMix
1.3.7
A new take on polymorphism in C++
|
#include "global.hpp"
#include "domain.hpp"
#include "mixin_type_info.hpp"
#include "feature.hpp"
#include "preprocessor.hpp"
Macros | |
#define | I_DYNAMIX_MIXIN_NAME_FEATURE ::dynamix::internal::noop_feature |
#define | DYNAMIX_DECLARE_EXPORTED_MIXIN(export, mixin_type) |
Declares a dynamic library class as a mixin. More... | |
#define | DYNAMIX_DECLARE_MIXIN(mixin_type) DYNAMIX_DECLARE_EXPORTED_MIXIN(I_DYNAMIX_PP_EMPTY(), mixin_type) |
Declares a class as a mixin. More... | |
#define | DYNAMIX_DEFINE_MIXIN(mixin_type, mixin_features) |
defines a mixin More... | |
#define | dm_this ::dynamix::object_of(this) |
a pointer to the owning object of the current mixin More... | |
Functions | |
template<typename Mixin > | |
object * | dynamix::object_of (Mixin *mixin_addr) |
gets the object of a mixin More... | |
template<typename Mixin > | |
const object * | dynamix::object_of (const Mixin *mixin_addr) |
gets the object of a mixin More... | |
Functions and macros associated with mixin declaration, definition, and usage.
#define DYNAMIX_DECLARE_EXPORTED_MIXIN | ( | export, | |
mixin_type | |||
) |
Declares a dynamic library class as a mixin.
export | is the type of export. For example __declspec(dllexport) in Visual C++. |
mixin_type | is the class name of the declared mixin. |
When using mixins from dynamic libraries, use this macro in your headers to forward declare a class as a mixin. This may be included separately and doesn't need to be in the same header as the actual mixin class definition.
If the first parameter is empty, the macro is equivalent to DYNAMIX_DECLARE_MIXIN
#define DYNAMIX_DECLARE_MIXIN | ( | mixin_type | ) | DYNAMIX_DECLARE_EXPORTED_MIXIN(I_DYNAMIX_PP_EMPTY(), mixin_type) |
Declares a class as a mixin.
mixin_type | is the class name of the declared mixin. |
Call this in header files to forward declare a mixin type. This may be included separately and doesn't need to be in the same header as the actual mixin class definition.
#define DYNAMIX_DEFINE_MIXIN | ( | mixin_type, | |
mixin_features | |||
) |
defines a mixin
mixin_type | is the class name of the declared mixin. |
mixin_features | the mixin features |
The macro defines a mixin in the domain. Call this once per mixin in a compilation unit (.cpp file). A good idea is, if possible, to place it in the compilation unit of the mixin class itself.
To work properly, the macro needs to see a forward declaration of the mixin (by DYNAMIX_DECLARE_MIXIN or DYNAMIX_DECLARE_EXPORED_MIXIN).
If the mixin has no features, then dynamix::none
should be set as the last argument
#define dm_this ::dynamix::object_of(this) |
a pointer to the owning object of the current mixin
Much like this
is a pointer to the current class, dm_this
is a macro that, for mixins, points to the current object.
It is nothing more than dynamix::object_of(this)
DYNAMIX_NO_DM_THIS
before including the library's headers.object* dynamix::object_of | ( | Mixin * | mixin_addr | ) |
gets the object of a mixin
[in] | mixin_addr | the address of the mixin |
Returns the owning object of a given mixin.
int*
. It is a source of potential bugs if you don't make sure that the input pointer is a mixin, that is a part of an objectconst object* dynamix::object_of | ( | const Mixin * | mixin_addr | ) |
gets the object of a mixin
[in] | mixin_addr | the address of the mixin |
Returns the owning object of a given mixin.
int*
. It is a source of potential bugs if you don't make sure that the input pointer is a mixin, that is a part of an object