Interface Dynamic Library
Create class having a structure for passing arguments to the derived class on creation.
Interface Header
++
class DL_EXPORT RuntimeIface
{
public:
struct Parameters
{
explicit Parameters(int h) : Handle(h) {}
int Handle;
};
explicit RuntimeIface(const Parameters& params) = default;
virtual ~RuntimeIface();
virtual const char* getString() = 0;
};
#define SF_DECL_IFACE(InterfaceType, ParamType, FuncName)
Declares a public static function in the class where it is used.
Definition TClassRegistration.h:79
Interface Code
Only line using a macro for implementing the interface class.
++
#define SF_IMPL_IFACE(InterfaceType, ParamType, FuncName)
Implements the public static function in the class where it is used.
Definition TClassRegistration.h:90
Implementation Dynamic Library
Implementation Header
++
class RuntimeLibImplementationA : public RuntimeIface
{
public:
explicit RuntimeLibImplementationA(const Parameters& params);
const char* getString() override;
private:
std::string FMessage;
};
Implementation Code
This _DL_INFORMATION(...)
library information into the target.
See sf::DynamicLibraryInfo
++
R"(This is the description of the library and what it contains.
A second line of a multi lined description.)"
)
(
RuntimeIface, RuntimeIface::Parameters, Interface,
RuntimeLibImplementationA, "Class-A", "Actual name of the class."
)
RuntimeLibImplementationA::RuntimeLibImplementationA(const RuntimeIface::Parameters& params)
: RuntimeIface(params)
{
}
const char* RuntimeLibImplementationA::getString()
{
FMessage =
sf::string_format(
"Greetings from Class '%s' created by name '%s' ", _RTTI_TYPENAME.c_str(),
Interface().RegisterName(this).c_str());
return FMessage.c_str();
}
#define SF_DL_INFORMATION(name, description)
Definition TClassRegistration.h:27
#define SF_REG_CLASS(InterfaceType, ParamType, FuncName, DerivedType, RegName, Description)
Registers a derived type from the interface type.
Definition TClassRegistration.h:105
#define SF_RTTI_NOTIFY(f, a)
Definition dbgutils.h:265
#define DO_CLOG
Definition dbgutils.h:246
std::string string_format(const std::string &format, Args &&... args)
Better implementation of 'stringf' ?
Definition string.h:145