33 #ifndef __H__UG_BRIDGE__REGISTRY_IMPL__
34 #define __H__UG_BRIDGE__REGISTRY_IMPL__
62 std::string retValInfos, std::string paramInfos,
63 std::string tooltip, std::string help)
73 std::string retValInfos, std::string paramInfos,
74 std::string tooltip, std::string help)
79 std::string strippedMethodName = funcName;
80 std::string methodOptions;
81 std::string::size_type pos = strippedMethodName.find(
"|");
82 if(pos != std::string::npos){
83 methodOptions = strippedMethodName.substr(pos + 1, strippedMethodName.length() - pos);
84 strippedMethodName = strippedMethodName.substr(0, pos);
88 strippedMethodName =
TrimString(strippedMethodName);
92 if(strippedMethodName.empty())
95 "Trying to register empty function name.");
101 "Trying to register function '" << strippedMethodName <<
"' that"
116 methodOptions, group,
117 retValInfos, paramInfos,
122 "Trying to register function name '"<<funcName
123 <<
"', that is already used by another function in this registry.");
134 template <
typename TClass,
typename TBaseClass>
142 "Trying to register class name '"<<className
143 <<
"', that is already used by another class in this registry.");
146 if(className.empty())
149 "Trying to register empty class name.");
153 if(
typeid(TClass) ==
typeid(TBaseClass))
156 "Trying to register class '"<< className
157 <<
"' that derives from itself.");
161 if(boost::is_base_of<TBaseClass, TClass>::value ==
false)
164 "Trying to register class "<<className
165 <<
"with base class that is no base class.");
169 template <
typename TClass>
171 add_class_(std::string className, std::string group, std::string tooltip)
177 "Trying to register class name '"<<className
178 <<
"', that is already used by another class in this registry.");
184 "Trying to register class name '"<<className
185 <<
"', that is already used by another group in this registry.");
188 if(className.empty())
191 "Trying to register empty class name.");
197 "Trying to register class '" << className <<
"' that"
213 template <
typename TClass,
typename TBaseClass>
215 add_class_(std::string className, std::string group, std::string tooltip)
221 "Trying to register class name '"<<className
222 <<
"', that is already used by another class in this registry.");
228 "Trying to register class name '"<<className
229 <<
"', that is already used by another group in this registry.");
232 if(className.empty())
235 "Trying to register empty class name.");
241 "Trying to register class '" << className <<
"' that"
246 check_base_class<TClass, TBaseClass>(className);
260 ClassCastProvider::add_cast_func<TBaseClass, TClass>();
267 template <
typename TClass,
typename TBaseClass1,
typename TBaseClass2>
269 add_class_(std::string className, std::string group, std::string tooltip)
275 "Trying to register class name '"<<className
276 <<
"', that is already used by another class in this registry.");
282 "Trying to register class name '"<<className
283 <<
"', that is already used by another group in this registry.");
286 if(className.empty())
289 "Trying to register empty class name.");
295 "Trying to register class '" << className <<
"' that"
300 check_base_class<TClass, TBaseClass1>(className);
301 check_base_class<TClass, TBaseClass2>(className);
315 ClassCastProvider::add_cast_func<TBaseClass1, TClass>();
316 ClassCastProvider::add_cast_func<TBaseClass2, TClass>();
323 template <
typename TClass>
331 for(
size_t i = 0; i <
m_vClass.size(); ++i)
337 "Trying to get class with name '" <<
name
338 <<
"', that has not yet been registered to this Registry.");
location name
Definition: checkpoint_util.lua:128
provides the name for a class
Definition: class_name_provider.h:102
static const std::string & name()
name of this class
Definition: class_name_provider_impl.h:152
This template class represents real c++ classes in the registry.
Definition: class.h:699
Groups of Functions - useful to realize overloaded functions.
Definition: global_function.h:243
ExportedFunction * add_overload(TFunc f, ExportedFunction::ProxyFunc pf, const std::string &funcOptions, const std::string &group, const std::string &retValInfos, const std::string ¶mInfos, const std::string &tooltip, const std::string &help)
adds an overload. Returns false if the overload already existed.
Definition: global_function.h:261
This class describes a wrapper for a c++ - function, that is exported by ug.
Definition: global_function.h:186
Registry for functions and classes that are exported to scripts and visualizations.
Definition: registry.h:138
bool groupname_registered(const std::string &name)
returns true if groupname is already used by a class in this registry
Definition: registry.cpp:411
ExportedFunction * add_and_get_function(std::string funcName, TFunc func, std::string group="", std::string retValInfos="", std::string paramInfos="", std::string tooltip="", std::string help="")
Similar to add_function but returns the added function instead of the registry.
Definition: registry_impl.h:72
bool classname_registered(const std::string &name)
returns true if classname is already used by a class in this registry
Definition: registry.cpp:406
Registry & add_function(std::string funcName, TFunc func, std::string group="", std::string retValInfos="", std::string paramInfos="", std::string tooltip="", std::string help="")
adds a function to the registry
Definition: registry_impl.h:61
std::vector< ExportedFunctionGroup * > m_vFunction
registered functions
Definition: registry.h:315
ExportedFunctionGroup * get_exported_function_group(const std::string &name)
returns an exported function group by name
Definition: registry.cpp:431
std::vector< IExportedClass * > m_vClass
registered classes
Definition: registry.h:318
ExportedClass< TClass > & add_class_(std::string className, std::string group="", std::string tooltip="")
Register a class at this registry.
Definition: registry_impl.h:171
ExportedClass< TClass > & get_class_()
Get Reference to already registered class.
Definition: registry_impl.h:325
void check_base_class(const std::string &className)
performs some checks, throws error if something wrong
Definition: registry_impl.h:136
bool IsValidRegistryIdentifier(const std::string &name)
Definition: registry_util.cpp:54
std::string GetRegistryIdentifierMessage()
Definition: registry_util.cpp:62
string TrimString(const string &str)
Definition: string_util.cpp:104
function func(x, y, z, t, si)
#define UG_THROW_REGISTRY_ERROR(cls, msg)
Definition: error.h:76
Definition: global_function.h:341