25 #ifndef WMODULEFACTORY_H
26 #define WMODULEFACTORY_H
34 #include <boost/shared_ptr.hpp>
35 #include <boost/weak_ptr.hpp>
37 #include "../common/WSharedAssociativeContainer.h"
38 #include "WModuleCombinerTypes.h"
40 #include "WModuleLoader.h"
47 friend class WModuleFactoryTest;
52 typedef boost::shared_ptr< WModuleFactory >
SPtr;
57 typedef boost::shared_ptr< const WModuleFactory >
ConstSPtr;
98 boost::shared_ptr< WModule >
create( boost::shared_ptr< WModule > prototype, std::string uuid =
"" );
167 template <
typename T>
168 static bool isA( boost::shared_ptr< WModule > module );
182 boost::shared_ptr< WModule > module = boost::shared_ptr< WModule >()
207 static bool isPrototype( boost::shared_ptr< WModule > module );
261 template <
typename T>
265 return ( dynamic_cast< T* >( module.get() ) );
268 #endif // WMODULEFACTORY_H
std::set< boost::shared_ptr< WModule > > PrototypeContainerType
For shortening: a type defining a shared set of WModule pointers.
const boost::shared_ptr< WModule > getPrototypeByInstance(boost::shared_ptr< WModule > instance)
Finds a prototype using an instance of a module.
const boost::shared_ptr< WModule > getPrototypeByName(std::string name)
Finds a prototype using the specified name.
WCombinerTypes::WCompatiblesList getAllPrototypes()
Creates a list of WApplyCombiner for all modules known by the factory.
Class able to create a new copy of an arbitrary module.
static bool isA(boost::shared_ptr< WModule > module)
Checks whether the first instance can be casted to the second one.
std::set< boost::shared_ptr< WModule > >::iterator PrototypeContainerIteratorType
Iterator for the prototype set.
WSharedAssociativeContainer< PrototypeContainerType > PrototypeSharedContainerType
The alias for a shared container.
static boost::shared_ptr< WModuleFactory > m_instance
Singleton instance of WModuleFactory.
boost::shared_ptr< const WModuleFactory > ConstSPtr
Shared pointer to a const WModule.
boost::shared_ptr< WModule > create(boost::shared_ptr< WModule > prototype, std::string uuid="")
Create a new and initialized module using the specified prototype.
static bool isPrototype(boost::shared_ptr< WModule > module)
Checks whether the specified module is a prototype or an instantiated module.
WModuleLoader::SPtr m_moduleLoader
Loader class managing dynamically loaded modules in OpenWalnut.
static boost::shared_ptr< WModuleLoader > getModuleLoader()
Returns instance of the module loader.
static WModule::SPtr findByUUID(std::string uuid)
Find a module instance by UUID.
boost::shared_ptr< WModuleFactory > SPtr
Shared pointer to a WModule.
PrototypeSharedContainerType::ReadTicket getPrototypes() const
This method gives read access to the list of all prototypes.
virtual ~WModuleFactory()
Destructor.
WModuleFactory()
Constructors are protected because this is a Singleton.
boost::shared_ptr< WModule > SPtr
Shared pointer to a WModule.
static SPtr getModuleFactory()
Returns instance of the module factory to use to create modules.
static void initializeModule(boost::shared_ptr< WModule > module)
This method uses a newly created instance of WModule and initializes it properly. ...
std::vector< WModule::ConstSPtr > getPrototypesByType(MODULE_TYPE type)
Finds a prototype using an type.
std::set< boost::shared_ptr< WModule > >::const_iterator PrototypeContainerConstIteratorType
Const iterator for the prototype set.
WSharedAssociativeContainer< UuidModuleMap > m_uuidModuleMap
Keep track of uuids of each created module.
boost::shared_ptr< WModuleLoader > SPtr
Shared pointer abbreviation.
void load()
Loads the modules and creates prototypes.
PrototypeSharedContainerType m_prototypes
The module prototypes available.
const boost::shared_ptr< WModule > isPrototypeAvailable(std::string name)
Searches a prototype by name.
std::map< std::string, boost::weak_ptr< WModule > > UuidModuleMap
Mapping between a UUID and a module.
bool checkPrototype(boost::shared_ptr< WModule > module, PrototypeSharedContainerType::ReadTicket ticket)
Checks whether the specified module is a prototype or an instantiated module.
boost::shared_ptr< WSharedObjectTicketRead< PrototypeContainerType > > ReadTicket
Type for read tickets.
WCombinerTypes::WCompatiblesList getCompatiblePrototypes(boost::shared_ptr< WModule > module=boost::shared_ptr< WModule >())
Returns a set of module combiners with module combinations compatible with the specified one...