Scanframe Modular Application 0.1.0
Loading...
Searching...
No Matches
TClassRegistration.h File Reference
#include <misc/gen/DynamicLibraryInfo.h>
#include <misc/gen/Exception.h>
#include <misc/gen/TClosure.h>
#include <misc/gen/TVector.h>
#include <misc/gen/dbgutils.h>
#include <misc/global.h>
#include <misc/gen/TClassRegistration.hpp>
Include dependency graph for TClassRegistration.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  sf::TClassRegistration< T, P >
 Template class used to register derived classes from a (virtual) interface class. Registering name and description.
Example More...
 
class  sf::TClassRegistration< T, P >::entry_t
 Type of registered entry in the list. More...
 

Namespaces

namespace  sf
 

Macros

#define SF_DL_NAME_FUNC_NAME   "_dl_name_"
 Name of the function to resolve from a library to be able to set the library filename when dynamically loaded.
 
#define SF_DL_NAME_FUNC   _dl_name_
 
#define SF_DL_STRING_COPY(dest, src, sz)   strncpy(dest, src, sz)
 
#define SF_DL_INFORMATION(name, description)
 
#define SF_DL_NAME_FUNC_TYPE   const char* (*) (const char*)
 Type for casting a resolved function pointer to.
 
#define SF_DECL_IFACE(InterfaceType, ParamType, FuncName)
 Declares a public static function in the class where it is used. Where: InterfaceType: Global typename of the interface class (virtual base class). ParamType: Global typename of the parameters passed. FuncName: Name of the public function in the interface class for registering derived classes or to create them.
 
#define SF_IMPL_IFACE(InterfaceType, ParamType, FuncName)
 Implements the public static function in the class where it is used.
 
#define SF_REG_CLASS(InterfaceType, ParamType, FuncName, DerivedType, RegName, Description)
 Registers a derived type from the interface type. Where: DerivedType: The derived typename from InterfaceType RegName: Quoted character string containing the name. Description: Quoted character string holding the name.
 

Functions

const char * _dl_name_ (const char *name)
 Declaration of function to set and get the dynamic library name when loading.
 
std::string sf::getLibraryName ()
 function to get the library filename this function is called from.
 

Macro Definition Documentation

◆ SF_DECL_IFACE

#define SF_DECL_IFACE (   InterfaceType,
  ParamType,
  FuncName 
)
Value:
private: \
std::string _Register_Name_; \
\
public: \
friend class sf::TClassRegistration<InterfaceType, ParamType>;
Template class used to register derived classes from a (virtual) interface class. Registering name an...
Definition TClassRegistration.h:124

Declares a public static function in the class where it is used. Where: InterfaceType: Global typename of the interface class (virtual base class). ParamType: Global typename of the parameters passed. FuncName: Name of the public function in the interface class for registering derived classes or to create them.

◆ SF_DL_INFORMATION

#define SF_DL_INFORMATION (   name,
  description 
)
Value:
namespace \
{ \
const char* _dl_ = SF_DL_MARKER_BEGIN name SF_DL_NAME_SEPARATOR description SF_DL_MARKER_END; \
\
extern "C" TARGET_EXPORT const char* SF_DL_NAME_FUNC(const char* nm) \
{ \
static char storage[256]; \
if (nm) \
SF_DL_STRING_COPY(storage, nm, sizeof(storage)); \
return storage; \
} \
}
#define SF_DL_MARKER_BEGIN
Definition DynamicLibraryInfo.h:14
#define SF_DL_MARKER_END
Definition DynamicLibraryInfo.h:18
#define SF_DL_NAME_SEPARATOR
Definition DynamicLibraryInfo.h:9
#define SF_DL_NAME_FUNC
Definition TClassRegistration.h:13
#define TARGET_EXPORT
Definition target.h:81

Declaration of dynamically loadable library information and function for set/get the library filename.

◆ SF_DL_NAME_FUNC

#define SF_DL_NAME_FUNC   _dl_name_

◆ SF_DL_NAME_FUNC_NAME

#define SF_DL_NAME_FUNC_NAME   "_dl_name_"

Name of the function to resolve from a library to be able to set the library filename when dynamically loaded.

◆ SF_DL_NAME_FUNC_TYPE

#define SF_DL_NAME_FUNC_TYPE   const char* (*) (const char*)

Type for casting a resolved function pointer to.

◆ SF_DL_STRING_COPY

#define SF_DL_STRING_COPY (   dest,
  src,
  sz 
)    strncpy(dest, src, sz)

◆ SF_IMPL_IFACE

#define SF_IMPL_IFACE (   InterfaceType,
  ParamType,
  FuncName 
)
Value:
{ \
}
std::vector< entry_t > entries_t
Vector type to register implementations in.
Definition TClassRegistration.h:133

Implements the public static function in the class where it is used.

◆ SF_REG_CLASS

#define SF_REG_CLASS (   InterfaceType,
  ParamType,
  FuncName,
  DerivedType,
  RegName,
  Description 
)
Value:
namespace \
{ \
__attribute__((constructor)) void _## DerivedType## _() \
{ \
size_t dist = InterfaceType::FuncName().registerClass( \
RegName, Description, sf::TClassRegistration<InterfaceType, ParamType>::callback_t([](const ParamType& params) -> InterfaceType* { \
auto inst = new DerivedType(params); \
sf::TClassRegistration<InterfaceType, ParamType>::setRegisterName(inst, RegName); \
return inst; \
}) \
); \
} \
}

Registers a derived type from the interface type. Where: DerivedType: The derived typename from InterfaceType RegName: Quoted character string containing the name. Description: Quoted character string holding the name.

Function Documentation

◆ _dl_name_()

const char * _dl_name_ ( const char *  name)

Declaration of function to set and get the dynamic library name when loading.