cumbia 1.x
general purpose multi threaded library
Loading...
Searching...
No Matches
CumbiaPool Class Reference

used in combination with CuControlsFactoryPool, the class can be used to create applications that can connect to sources or targets belonging to different control system frameworks More...

#include <cumbiapool.h>

Public Member Functions

 CumbiaPool ()
 the class constructor More...
 
void registerCumbiaImpl (const std::string &name, Cumbia *cumbia)
 register a cumbia implementation with a given domain More...
 
void setSrcPatterns (const std::string &name, const std::vector< std::string > &regexps)
 associate to a domain name a list of regular expressions describing the source syntax for that domain. More...
 
void clearSrcPatterns (const std::string &name)
 remove the source patterns for the given domain More...
 
void unregisterCumbiaImpl (const std::string &name)
 remove the domain from the list of the registered ones. More...
 
Cumbiaget (const std::string &name) const
 get the Cumbia implementation that was registered with the given domain name More...
 
CumbiagetBySrc (const std::string &src) const
 Calls get with the domain extracted from the full source name "src". More...
 
CumbiaguessBySrc (const std::string &src) const
 given the source string, tries to match it with the registered patterns in order to return the associated Cumbia implementation. More...
 
bool isEmpty () const
 returns true if the CumbiaPool has no registered domains/Cumbia implementations More...
 
const std::vector< std::string > names () const
 

Detailed Description

used in combination with CuControlsFactoryPool, the class can be used to create applications that can connect to sources or targets belonging to different control system frameworks

Declare CumbiaPool in your main class so that it's visible across the whole application.

class GenericClient : public QWidget
{
Q_OBJECT
public:
// ...
private:
CumbiaPool *cu_pool; // to use in combination with CuControlsFactoryPool
CuControlsFactoryPool m_ctrl_factory_pool;
};
used in combination with CuControlsFactoryPool, the class can be used to create applications that can...
Definition: cumbiapool.h:65

You need to instantiate the desired Cumbia engines and register them with registerCumbiaImpl. Then you must call setSrcPatterns for each "domain" name (e.g. "tango" or "epics") The following code shows an example. It integrates the considerations done in the CuControlsFactoryPool documentation.

// cumbia engine: CumbiaEpics
CumbiaEpics* cuep = new CumbiaEpics(new CuThreadFactoryImpl(), new QThreadsEventBridgeFactory());
// register cumbia engine with the "domain" name, a string used to identify it later
cu_pool->registerCumbiaImpl("epics", cuep);
// see CuControlsFactoryPool documentation
m_ctrl_factory_pool.registerImpl("epics", CuEpReaderFactory());
m_ctrl_factory_pool.registerImpl("epics", CuEpWriterFactory());
CuEpicsWorld ew;
// CuEpicsWorld.srcPatterns provides default patterns for the epics source patterns
m_ctrl_factory_pool.setSrcPatterns("epics", ew.srcPatterns());
cu_pool->setSrcPatterns("epics", ew.srcPatterns());
// tango engine: CumbiaTango
CumbiaTango* cuta = new CumbiaTango(new CuThreadFactoryImpl(), new QThreadsEventBridgeFactory());
cu_pool->registerCumbiaImpl("tango", cuta);
m_ctrl_factory_pool.registerImpl("tango", CuTWriterFactory());
m_ctrl_factory_pool.registerImpl("tango", CuTReaderFactory());
// CuTangoWorld.srcPatterns provides default patterns for the tango source patterns
CuTangoWorld tw;
m_ctrl_factory_pool.setSrcPatterns("tango", tw.srcPatterns());
cu_pool->setSrcPatterns("tango", tw.srcPatterns());
// ...
ui->setupUi(this);
implementation of CuThreadFactoryImplI used to instantiate and return a new CuThread
Definition: cuthreadfactoryimpl.h:17

Constructor & Destructor Documentation

◆ CumbiaPool()

CumbiaPool::CumbiaPool ( )

the class constructor

Creates an empty CumbiaPool with no registered implementations

Note
This class is used in combination with cumbia-qtcontrols CuControlsFactoryPool to set up a multi engine environment for a cumbia/Qt application. cumbia-qtcontrols CuControlsFactoryPool documentation is a recommended reading.

Member Function Documentation

◆ clearSrcPatterns()

void CumbiaPool::clearSrcPatterns ( const std::string &  name)

remove the source patterns for the given domain

Parameters
domainthe domain name whose patterns will be removed

◆ get()

Cumbia * CumbiaPool::get ( const std::string &  domain) const

get the Cumbia implementation that was registered with the given domain name

Parameters
domainthe name of the domain associated with a Cumbia implementation through a previous call to registerCumbiaImpl
Returns
the Cumbia implementation for the given domain, if it had been registered
the first registered Cumbia implementation if no implementation has been found with that domain name
NULL if no Cumbia implementation have been registered in the CumbiaPool

Referenced by getBySrc(), and guessBySrc().

◆ getBySrc()

Cumbia * CumbiaPool::getBySrc ( const std::string &  src) const

Calls get with the domain extracted from the full source name "src".

Parameters
srcthe name of the data source. Must begin with the domain name followed by ://, for example epics://foo:bar

References get(), guessBySrc(), and perr.

◆ guessBySrc()

Cumbia * CumbiaPool::guessBySrc ( const std::string &  src) const

given the source string, tries to match it with the registered patterns in order to return the associated Cumbia implementation.

Parameters
srcthe source name
Returns
a Cumbia implementation, if one was found matching src, or NULL otherwise.

References get(), and i.

Referenced by getBySrc().

◆ isEmpty()

bool CumbiaPool::isEmpty ( ) const

returns true if the CumbiaPool has no registered domains/Cumbia implementations

Returns
true if the CumbiaPool has no registered domains/Cumbia implementations, false otherwise

◆ names()

const std::vector< std::string > CumbiaPool::names ( ) const

◆ registerCumbiaImpl()

void CumbiaPool::registerCumbiaImpl ( const std::string &  domain,
Cumbia cumbia 
)

register a cumbia implementation with a given domain

Parameters
domaina string identifying a domain name, e.g. "tango" or "epics"
cumbia,aninstance of a Cumbia implementation, such as CumbiaEpics or CumbiaTango.

◆ setSrcPatterns()

void CumbiaPool::setSrcPatterns ( const std::string &  domain,
const std::vector< std::string > &  regexps 
)

associate to a domain name a list of regular expressions describing the source syntax for that domain.

std::vector<std::string> epics_patterns, tango_patterns;
tango_patterns.push_back(".+/.+"); // e.g. test/device/1/double_scalar
tango_patterns.push_back(".+->.+"); // e.g. test/device/1->DevLong
cu_pool->setSrcPatterns("tango", tango_patterns);

◆ unregisterCumbiaImpl()

void CumbiaPool::unregisterCumbiaImpl ( const std::string &  domain)

remove the domain from the list of the registered ones.

Parameters
domainthe domain with this name will be removed from the CumbiaPool domain list

The documentation for this class was generated from the following files: