![]() |
ChimeraTK-DeviceAccess 03.25.00
|
#include <boost/bind/bind.hpp>#include <boost/function.hpp>#include <boost/fusion/include/at_key.hpp>#include <boost/fusion/include/for_each.hpp>
Include dependency graph for VirtualFunctionTemplate.h:
This graph shows which files directly or indirectly include this file:Go to the source code of this file.
Macros | |
| #define | DEFINE_VIRTUAL_FUNCTION_TEMPLATE_VTABLE(functionName, ...) |
| Define a virtual function template with the given function name and signature in the base class. | |
| #define | DEFINE_VIRTUAL_FUNCTION_OVERRIDE_VTABLE(BaseClass, functionName, ...) DEFINE_VIRTUAL_FUNCTION_TEMPLATE_VTABLE(BaseClass##functionName, __VA_ARGS__) |
| Define an override for a function template with the given function name and signature in the base class. | |
| #define | CALL_VIRTUAL_FUNCTION_TEMPLATE(functionName, templateArgument, ...) boost::fusion::at_key<templateArgument>(functionName##_vtable.table)(__VA_ARGS__) |
| Execute the virtual function template call using the vtable defined with the DEFINE_VIRTUAL_FUNCTION_TEMPLATE_VTABLE macro. | |
| #define | CALL_BASE_FUNCTION_TEMPLATE(BaseClass, functionName, templateArgument, ...) boost::fusion::at_key<templateArgument>(BaseClass##functionName##_vtable.table)(__VA_ARGS__) |
| Execute the virtual function template call to the base implementation of the function. | |
| #define | FILL_VIRTUAL_FUNCTION_TEMPLATE_VTABLE(functionName) |
| Fill the vtable of a virtual function template defined with DEFINE_VIRTUAL_FUNCTION_TEMPLATE. | |
| #define | OVERRIDE_VIRTUAL_FUNCTION_TEMPLATE(BaseClass, functionName) |
| Save the old vtable to be accessible by CALL_BASE_FUNCTION_TEMPLATE and overwrite it with the new implementation. | |
| #define | FILL_VIRTUAL_FUNCTION_TEMPLATE_VTABLE_STANDALONE(functionName, numberOfArguments) FILL_VIRTUAL_FUNCTION_TEMPLATE_VTABLE(functionName) |
| Compatibility only, do not use. | |
| #define | DEFINE_VIRTUAL_FUNCTION_TEMPLATE_VTABLE_FILLER(className, functionName, numberOfArguments) class UslessVTableFillerClass##functionName {} |
| Compatibility, do not use. | |
| #define CALL_BASE_FUNCTION_TEMPLATE | ( | BaseClass, | |
| functionName, | |||
| templateArgument, | |||
| ... | |||
| ) | boost::fusion::at_key<templateArgument>(BaseClass##functionName##_vtable.table)(__VA_ARGS__) |
Execute the virtual function template call to the base implementation of the function.
The function must have been overriden by DEFINE_VIRTUAL_FUNCTION_OVERRIDE_VTABLE and OVERRIDE_VIRTUAL_FUNCTION_TEMPLATE
Definition at line 72 of file VirtualFunctionTemplate.h.
| #define CALL_VIRTUAL_FUNCTION_TEMPLATE | ( | functionName, | |
| templateArgument, | |||
| ... | |||
| ) | boost::fusion::at_key<templateArgument>(functionName##_vtable.table)(__VA_ARGS__) |
Execute the virtual function template call using the vtable defined with the DEFINE_VIRTUAL_FUNCTION_TEMPLATE_VTABLE macro.
It is recommended to put this macro into a function template with the same name and signature, so the user of the class can call the virtual function template conveniently.
Implementation note: This function template could automatically be provided via the DEFINE_VIRTUAL_FUNCTION_TEMPLATE_VTABLE macro. This is not done, because it wouldn't allow to specify default values for the parameters, and the proper signature would not be visible in Doxygen.
Definition at line 64 of file VirtualFunctionTemplate.h.
| #define DEFINE_VIRTUAL_FUNCTION_OVERRIDE_VTABLE | ( | BaseClass, | |
| functionName, | |||
| ... | |||
| ) | DEFINE_VIRTUAL_FUNCTION_TEMPLATE_VTABLE(BaseClass##functionName, __VA_ARGS__) |
Define an override for a function template with the given function name and signature in the base class.
Semantics apply as in DEFINE_VIRTUAL_FUNCTION_TEMPLATE.
Definition at line 52 of file VirtualFunctionTemplate.h.
| #define DEFINE_VIRTUAL_FUNCTION_TEMPLATE_VTABLE | ( | functionName, | |
| ... | |||
| ) |
Define a virtual function template with the given function name and signature in the base class.
The signature must contain the typename template argument called "T". So if you e.g. would want to define a function like this:
template<typename UserType> virtual NDRegisterAccessor<UserType> getRegisterAccessor(std::string name);
you should call this macro in the base class like this:
DEFINE_VIRTUAL_FUNCTION_TEMPLATE( getRegisterAccessor, T(std::string) );
The virtual function can be called using the CALL_VIRTUAL_FUNCTION_TEMPLATE macro. It is recommended to define the function template in the base class (without the virtual keyword of course) and implement it by using this macro.
In the derived class, the function template must be implemented with the same signature, and the vtable for this virtual function template must be filled differently depending on whether you want to (be able to) call the base class's implementation or not:
Note: the signature is passed through the VA_ARGS variable macro arguments, as it may contain commas.
Definition at line 36 of file VirtualFunctionTemplate.h.
| #define DEFINE_VIRTUAL_FUNCTION_TEMPLATE_VTABLE_FILLER | ( | className, | |
| functionName, | |||
| numberOfArguments | |||
| ) | class UslessVTableFillerClass##functionName {} |
Compatibility, do not use.
Definition at line 102 of file VirtualFunctionTemplate.h.
| #define FILL_VIRTUAL_FUNCTION_TEMPLATE_VTABLE | ( | functionName | ) |
Fill the vtable of a virtual function template defined with DEFINE_VIRTUAL_FUNCTION_TEMPLATE.
Use this macro inside the constructor of the derived class.
Definition at line 78 of file VirtualFunctionTemplate.h.
| #define FILL_VIRTUAL_FUNCTION_TEMPLATE_VTABLE_STANDALONE | ( | functionName, | |
| numberOfArguments | |||
| ) | FILL_VIRTUAL_FUNCTION_TEMPLATE_VTABLE(functionName) |
Compatibility only, do not use.
Definition at line 98 of file VirtualFunctionTemplate.h.
| #define OVERRIDE_VIRTUAL_FUNCTION_TEMPLATE | ( | BaseClass, | |
| functionName | |||
| ) |
Save the old vtable to be accessible by CALL_BASE_FUNCTION_TEMPLATE and overwrite it with the new implementation.
Definition at line 87 of file VirtualFunctionTemplate.h.