33 #include <rsc/logging/Logger.h> 34 #include <rsc/logging/LoggerFactory.h> 35 #include <rsc/misc/langutils.h> 36 #include <rsc/runtime/NoSuchObject.h> 37 #include <rsc/runtime/TypeStringTools.h> 38 #include <rsc/runtime/Printable.h> 39 #include <rsc/patterns/Factory.h> 41 #include <boost/type_traits.hpp> 46 #include "rsb/rsbexports.h" 51 template <
typename Interface>
71 template <
typename Interface>
72 class ConnectorFactory:
public rsc::patterns::Factory<std::string, Interface>,
73 public rsc::runtime::Printable {
91 name(name), schemas(schemas), remote(remote), options(options) {
92 this->options.insert(
"enabled");
137 }
else if (this->
name == other.
name) {
158 <<
", schemas = " << this->schemas
159 <<
", remote = " << this->remote
160 <<
", options = " << this->
options;
171 typedef rsc::patterns::Factory<std::string, Interface>
Factory;
174 typedef std::map<std::string, ConnectorInfo>
InfoMap;
177 logger(rsc::logging::Logger::getLogger(
"rsb.transport.ConnectorFactory<" + rsc::runtime::typeName<Interface>() +
">")) {
190 typename InfoMap::const_iterator it = this->
infos.find(name);
191 if (it == this->
infos.end()) {
192 throw rsc::runtime::NoSuchObject(name);
198 std::set<ConnectorInfo> result;
200 for (
typename InfoMap::const_iterator it = this->
infos.begin();
201 it != this->
infos.end(); ++it) {
202 result.insert(it->second);
220 const CreateFunction& constructor,
221 const std::set<std::string>&
schemas = std::set<std::string>(),
223 const std::set<std::string>&
options = std::set<std::string>()) {
224 RSCINFO(this->logger,
"Registering connector " 226 <<
" for schemas " <<
schemas);
228 Factory::impls().register_(name, constructor);
231 this->
infos.insert(std::make_pair(name, info));
235 const CreateFunction& constructor,
const std::string& schema,
237 const std::set<std::string>&
options = std::set<std::string>()) {
239 schemas.insert(schema);
246 const ImplMapProxy& implementations = Factory::impls();
248 for (
typename ImplMapProxy::const_iterator it = implementations.begin(); it
249 != implementations.end(); ++it) {
std::map< std::string, ConnectorInfo > InfoMap
Instances of this class describe capabilities and properties of connector implementations.
void printContents(std::ostream &stream) const
Factory::CreateFunction CreateFunction
friend InPushFactory & getInPushFactory()
bool operator<(const ConnectorInfo &other) const
void registerConnector(const std::string &name, const CreateFunction &constructor, const std::set< std::string > &schemas=std::set< std::string >(), bool remote=true, const std::set< std::string > &options=std::set< std::string >())
For the connector implementation named name, register the construct function constructor, supported schemas schemas and recognized configuration options options.
rsc::logging::LoggerPtr logger
ConnectorInfo getConnectorInfo(const std::string &name) const
Return information regarding the connector implementation named name.
std::set< ConnectorInfo > getConnectorInfos() const
std::set< std::string > OptionList
ConnectorFactory< InPullConnector > InPullFactory
ConnectorFactory< OutConnector > OutFactory
std::set< std::string > SchemaList
void registerConnector(const std::string &name, const CreateFunction &constructor, const std::string &schema, bool remote=true, const std::set< std::string > &options=std::set< std::string >())
ConnectorInfo(const std::string &name, const SchemaList &schemas, bool remote, const OptionList &options)
void printContents(std::ostream &stream) const
std::string getName() const
Return the name of the implementation.
rsc::patterns::Factory< std::string, Interface > Factory
friend InPullFactory & getInPullFactory()
InPullFactory & getInPullFactory()
OptionList getOptions() const
Return a list of option names describing configurations options recognized by the implementation...
bool isRemote() const
Return "remoteness" of the implementation.
friend OutFactory & getOutFactory()
InPushFactory & getInPushFactory()
Factory::ImplMapProxy ImplMapProxy
OutFactory & getOutFactory()
ConnectorFactory< InPushConnector > InPushFactory
Objects of this class are specialized factories that construct Connector objects and provide introspe...
SchemaList getSchemas() const
Return the set of schemas supported by the connector implementation.