libbio
Loading...
Searching...
No Matches
Macros
ConstructorMacros.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define BIO_DEFAULT_IDENTIFIABLE_CONSTRUCTORS(ns, class, ...)
 
#define BIO_DEFAULT_IDENTIFIABLE_CONSTRUCTORS_WITH_COMMON_CONSTRUCTOR(ns, class, ...)
 

Macro Definition Documentation

◆ BIO_DEFAULT_IDENTIFIABLE_CONSTRUCTORS

#define BIO_DEFAULT_IDENTIFIABLE_CONSTRUCTORS (   ns,
  class,
  ... 
)
Value:
class() : \
ns::Class< class >(this, __VA_ARGS__) \
{} \
explicit class(const ::bio::Name& name) : \
ns::Class< class >(this, name, __VA_ARGS__) \
{} \
explicit class(const ::bio::Id& id) : \
ns::Class< class >(this, id, __VA_ARGS__) \
{}

Defines constructors for classes deriving from chemical::Class and beyond.
These will allow you to construct your object with either a name or an id.
We also define the empty constructor for when neither name nor id are supplied.

IMPORTANT: despite using VA_ARGS, this will fail if nothing more than the namespace and class are provided.
At a minimum, you MUST ALSO INCLUDE THE Filter AFTER class!
e.g. BIO_DEFAULT_IDENTIFIABLE_CONSTRUCTORS(my_namespace, MyClass, filter::Default())

NOTE: if your class has multiple template args or otherwise uses commas in its name, you must enclose it in BIO_SINGLE_ARG() so as to not have it be considered part of the VA_ARGS.

Parameters
nsthe namespace of the class
classthe name of the class
...all arguments to the ns::Class<class>(...) constructor.

◆ BIO_DEFAULT_IDENTIFIABLE_CONSTRUCTORS_WITH_COMMON_CONSTRUCTOR

#define BIO_DEFAULT_IDENTIFIABLE_CONSTRUCTORS_WITH_COMMON_CONSTRUCTOR (   ns,
  class,
  ... 
)
Value:
class() : \
ns::Class< class >(this, __VA_ARGS__) \
{ \
this->CommonConstructor(); \
} \
explicit class(const ::bio::Name& name) : \
ns::Class< class >(this, name, __VA_ARGS__) \
{ \
this->CommonConstructor(); \
} \
explicit class(const ::bio::Id& id) : \
ns::Class< class >(this, id, __VA_ARGS__) \
{ \
this->CommonConstructor(); \
}

Defines constructors for classes deriving from chemical::Class and beyond.
All constructors call a CommonConstructor() method with no args.
These will allow you to construct your object with either a name or an id.
We also define the empty constructor for when neither name nor id are supplied.

IMPORTANT: despite using VA_ARGS, this will fail if nothing more than the namespace and class are provided.
At a minimum, you MUST ALSO INCLUDE THE Filter AFTER class!
e.g. BIO_DEFAULT_IDENTIFIABLE_CONSTRUCTORS(my_namespace, MyClass, filter::Default())

NOTE: if your class has multiple template args or otherwise uses commas in its name, you must enclose it in BIO_SINGLE_ARG() so as to not have it be considered part of the VA_ARGS.

Parameters
nsthe namespace of the class
classthe name of the class
...all arguments to the ns::Class<class>(...) constructor.