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>
73 private rsc::patterns::Singleton< ConnectorFactory<Interface> >,
74 public rsc::runtime::Printable {
100 name(name), schemas(schemas), remote(remote), options(options) {
101 this->options.insert(
"enabled");
146 }
else if (this->
name == other.
name) {
167 <<
", schemas = " << this->
schemas
168 <<
", remote = " << this->
remote
169 <<
", options = " << this->
options;
177 return rsc::patterns::Singleton< ConnectorFactory<Interface> >::getInstance();
183 typedef rsc::patterns::Factory<std::string, Interface>
Factory;
186 typedef std::map<std::string, ConnectorInfo>
InfoMap;
189 logger(rsc::logging::Logger::getLogger(
"rsb.transport.ConnectorFactory<" + rsc::runtime::typeName<Interface>() +
">")) {
202 typename InfoMap::const_iterator it = this->
infos.find(name);
203 if (it == this->
infos.end()) {
204 throw rsc::runtime::NoSuchObject(name);
210 std::set<ConnectorInfo> result;
212 for (
typename InfoMap::const_iterator it = this->
infos.begin();
213 it != this->
infos.end(); ++it) {
214 result.insert(it->second);
233 const std::set<std::string>& schemas = std::set<std::string>(),
235 const std::set<std::string>& options = std::set<std::string>()) {
236 RSCINFO(this->
logger,
"Registering connector "
238 <<
" for schemas " << schemas);
240 Factory::impls().register_(name, constructor);
243 this->
infos.insert(std::make_pair(name, info));
249 const std::set<std::string>& options = std::set<std::string>()) {
250 std::set<std::string> schemas;
251 schemas.insert(schema);
260 for (
typename ImplMapProxy::const_iterator it = implementations.begin(); it
261 != implementations.end(); ++it) {
267 template <
typename Interface>
268 ConnectorFactory<Interface>& ConnectorFactory<Interface>::getInstance() {
281 if (boost::is_same<Interface, InPullConnector>::value) {
283 }
else if (boost::is_same<Interface, InPushConnector>::value) {
285 }
else if (boost::is_same<Interface, OutConnector>::value) {
289 return (*(ConnectorFactory<Interface>*) 0);