ug4
|
Factory providing LuaUserData. More...
#include <lua_user_data.h>
Static Public Member Functions | |
static SmartPtr< LuaUserData< TData, dim, TRet > > | create (const std::string &name) |
Protected Member Functions | |
LuaUserDataFactory () | |
private constructor, since singleton More... | |
LuaUserDataFactory (const LuaUserDataFactory &) | |
LuaUserDataFactory & | operator= (const LuaUserDataFactory &) |
Static Protected Member Functions | |
static LuaUserDataFactory< TData, dim, TRet > & | instance () |
singleton provider More... | |
static SmartPtr< LuaUserData< TData, dim, TRet > > | provide_or_create (const std::string &name) |
returns new Data if not already created, already existing else More... | |
static void | remove (const std::string &name) |
removes the user data More... | |
Static Protected Attributes | |
static std::map< std::string, std::pair< LuaUserData< TData, dim, TRet > *, int * > > | m_mData = std::map<std::string, std::pair<LuaUserData<TData,dim,TRet>*, int*> >() |
storage of already created data More... | |
Friends | |
class | LuaUserData< TData, dim, TRet > |
Factory providing LuaUserData.
This class is a singleton providing LuaUserData for a given callback name. The factory creates a new LuaUserData and returns it as a SmartPtr if no Data has been created with the same callback name before. It already a LuaUserData using the same callback exists, then a SmartPtr to that instance is returned. Internally, therefore plain pointers and reference counters of the created SmartPtrs are stored and LuaUserData unregister from the List of created LuaUserData in this factory when their destructor is called.
TData | Data produced by LuaUserData |
dim | world dimension |
TRet | bool flag or void |
|
inlineprotected |
private constructor, since singleton
|
protected |
|
inlinestatic |
Returns a LuaUserDataas a SmartPtr for a callback name. If a LuaUserData has already been created by the factory it simply returns a new SmartPtr without creation, else the LuaUserData is created. All LuaUserData store internally, if they have been created by a factory, and if so they unregister from the factory when their destructor is called.
NOTE: In order to allow any garbage collection of the LuaUserData, therefore this factory can not store the LuaUserData as a SmartPtr, but as a plain pointer together with the reference counter.
name | lua callback name |
References ug::LuaUserDataFactory< TData, dim, TRet >::instance(), and name.
|
inlinestaticprotected |
singleton provider
Referenced by ug::LuaUserDataFactory< TData, dim, TRet >::create().
|
protected |
|
staticprotected |
returns new Data if not already created, already existing else
References SmartPtr< T, FreePolicy >::get(), make_sp(), name, PROFILE_CALLBACK, and SmartPtr< T, FreePolicy >::refcount_ptr().
|
staticprotected |
removes the user data
References name, and UG_THROW.
Referenced by ug::LuaUserData< TData, dim, TRet >::~LuaUserData().
|
friend |
|
staticprotected |
storage of already created data