30 #include <boost/filesystem/fstream.hpp> 32 #include <rsc/config/Configuration.h> 33 #include <rsc/config/Environment.h> 35 #include <rsc/logging/OptionBasedConfigurator.h> 37 #include <rsc/plugins/Manager.h> 38 #include <rsc/plugins/Configurator.h> 40 #include <rsb/Version.h> 67 std::map<
typename C::value_type::first_type,
68 typename C::value_type::second_type>
70 typedef typename C::value_type::first_type first_type;
71 typedef typename C::value_type::second_type second_type;
73 typedef typename C::const_iterator const_iterator;
75 std::map<first_type, second_type> result;
76 for (const_iterator it = container.begin(); it != container.end(); ++it) {
79 result[it->first] = it->second;
82 if (result.find(it->second) != result.end()) {
83 throw std::invalid_argument(
86 "Multiple wire-schemas (%1%, %2%) selected for data-type %3%.\n" 87 "Probably you wrote the lines transport.<name>.cpp.%1% = %3% " 88 "and transport.<name>.cpp.%2% = %3% in your rsb config. One of " 89 "these should be deleted.")
96 result[it->second] = it->first;
100 throw std::runtime_error(
"got unexpected serialization direction");
109 rsc::logging::LoggerPtr logger) {
111 RSCDEBUG(logger,
"Supplied connector options " << options);
124 RSCDEBUG(logger,
"Converter configuration for transport `" 131 = converterRepository<string>()
132 ->getConvertersForSerialization
133 (converterSelectionToMap(config.
getConverters(), direction));
135 case DESERIALIZATION:
137 = converterRepository<string>()
138 ->getConvertersForDeserialization
139 (converterSelectionToMap(config.
getConverters(), direction));
143 throw std::runtime_error(
"got unexpected serialization direction");
145 RSCDEBUG(logger,
"Selected converters for transport `" 146 << config.
getName() <<
"': " << converters);
147 options[
"converters"] = converters;
164 if (factoryWhileLoadingPlugins) {
174 : phase(phase), enabled(enabled) {
176 std::cerr <<
"Starting processing " << this->phase <<
" configuration" 177 << std::endl << std::endl;
183 std::cerr << std::endl
184 <<
"Finished processing " << this->phase <<
" configuration" 185 << std::endl << std::endl;
194 logger(Logger::getLogger(
"rsb.Factory")),
195 pluginManager(new rsc::plugins::Manager()),
199 bool debugConfig = getEnvironmentVariable(
"RSB_CONFIG_DEBUG").get();
205 rsc::logging::OptionBasedConfigurator configurator;
210 RSCINFO(this->
logger,
"Registering default implementations");
221 RSCINFO(this->
logger,
"Processing plugin configuration");
225 factoryWhileLoadingPlugins =
this;
227 vector<boost::filesystem::path> defaultPath;
231 defaultPath.push_back(userHomeDirectory()
232 / (
"." + Version::buildPluginPathSuffix()));
233 }
catch (
const runtime_error& e) {
235 "Failed to determine user-specific plugin directory: " 238 defaultPath.push_back(Version::libdir() / Version::buildPluginPathSuffix());
239 rsc::plugins::Configurator configurator(
pluginManager, defaultPath);
241 configurator.execute(
true);
243 factoryWhileLoadingPlugins = NULL;
246 factoryWhileLoadingPlugins = NULL;
261 for (set<string>::const_iterator it = availableTransports.begin();
262 it != availableTransports.end(); ++it) {
281 std::cerr <<
"Default participant configuration" << std::endl
289 RSCWARN(
logger,
"No transports are enabled. This is probably a" 290 " configuration error or an internal RSB error.");
300 OptionHandler& handler,
302 configure(handler,
"rsb.conf", environmentVariablePrefix, 0, 0, stripPrefix,
303 Version::installPrefix(), CONFIG_DEBUG_ENVIRONMENT_VARIABLE,
304 defaultConfigurationFiles(CONFIG_FILES_ENVIRONEMNT_VARIABLE));
316 const string& dataType,
356 listenerConfig, informerConfig, callback));
381 listenerConfig, informerConfig));
399 boost::recursive_mutex::scoped_lock lock(
configMutex);
404 boost::recursive_mutex::scoped_lock lock(
configMutex);
408 vector<InPullConnectorPtr>
411 vector<InPullConnectorPtr> connectors;
412 set<ParticipantConfig::Transport> configuredTransports = config.
getTransports();
413 for (set<ParticipantConfig::Transport>::const_iterator transportIt =
414 configuredTransports.begin(); transportIt
415 != configuredTransports.end(); ++transportIt) {
416 RSCDEBUG(
logger,
"Trying to add connector " << *transportIt);
419 .createInst(transportIt->getName(),
420 prepareConnectorOptions(*transportIt,
423 }
catch (
const exception& e) {
424 throw runtime_error(boost::str(boost::format(
"Error configuring connector `%1%', in-pull: %2%")
425 % transportIt->getName() % e.what()));
431 vector<InPushConnectorPtr>
434 vector<InPushConnectorPtr> connectors;
435 set<ParticipantConfig::Transport> configuredTransports = config.
getTransports();
436 for (set<ParticipantConfig::Transport>::const_iterator transportIt =
437 configuredTransports.begin(); transportIt
438 != configuredTransports.end(); ++transportIt) {
439 RSCDEBUG(
logger,
"Trying to add connector " << *transportIt);
442 .createInst(transportIt->getName(),
443 prepareConnectorOptions(*transportIt,
446 }
catch (
const exception& e) {
447 throw runtime_error(boost::str(boost::format(
"Error configuring connector `%1%', in-push: %2%")
448 % transportIt->getName() % e.what()));
454 vector<OutConnectorPtr>
457 vector<OutConnectorPtr> connectors;
458 set<ParticipantConfig::Transport> configuredTransports = config.
getTransports();
459 for (set<ParticipantConfig::Transport>::const_iterator transportIt =
460 configuredTransports.begin(); transportIt
461 != configuredTransports.end(); ++transportIt) {
462 RSCDEBUG(
logger,
"Trying to add connector " << *transportIt);
465 .createInst(transportIt->getName(),
466 prepareConnectorOptions(*transportIt,
469 }
catch (
const exception& e) {
470 throw runtime_error(boost::str(boost::format(
"Error configuring connector `%1%', out: %2%")
471 % transportIt->getName() % e.what()));
rsc::runtime::Properties getOptions() const
Returns the specified options for the transport.
void registerDefaultEventProcessingStrategies()
A derived Method class which can be used to invoke methods on a remote LocalServer object...
bool isRemote(const string &transportName)
Returns true if transportName names a remote transport.
std::vector< transport::OutConnectorPtr > createOutConnectors(const ParticipantConfig &config)
boost::shared_ptr< RemoteMethod > RemoteMethodPtr
boost::shared_ptr< LocalServer > LocalServerPtr
boost::shared_ptr< LocalMethod > LocalMethodPtr
const std::string CONFIG_DEBUG_ENVIRONMENT_VARIABLE
std::string getName() const
Returns the name of this transport description.
boost::signals2::signal< void(Participant *)> SignalParticipantDestroyed
ParticipantConfig getDefaultParticipantConfig() const
Returns the default configuration for new participants.
ConfigDebugPrinter(const std::string &phase, bool enabled)
SignalParticipantDestroyedPtr getSignalParticipantDestroyed()
void addTransport(const Transport &transport)
Adds a transport to the list of desired transport mechanisms.
ConverterNames getConverters() const
boost::shared_ptr< Reader > ReaderPtr
ListenerPtr createListener(const Scope &scope, const ParticipantConfig &config=getFactory().getDefaultParticipantConfig(), ParticipantPtr parent=ParticipantPtr())
Creates a new listener for the specified scope.
Factory & getFactory()
Returns a factory for client-level RSB objects.
std::vector< transport::InPushConnectorPtr > createInPushConnectors(const ParticipantConfig &config)
patterns::LocalServerPtr createLocalServer(const Scope &scope, const ParticipantConfig &listenerConfig=getFactory().getDefaultParticipantConfig(), const ParticipantConfig &informerConfig=getFactory().getDefaultParticipantConfig(), ParticipantPtr parent=ParticipantPtr())
Creates a Server object that exposes methods under the scope scope.
set< string > getAvailableTransports(unsigned int requiredDirections)
Returns the names of all available transports which support requiredDirections.
static void provideConfigOptions(const std::string &environmentVariablePrefix, rsc::config::OptionHandler &handler, bool stripPrefix=true)
Provides the default configuration options for RSB to the specified handler.
SignalParticipantDestroyedPtr signalParticipantDestroyed
boost::shared_ptr< Listener > ListenerPtr
boost::shared_ptr< OutConnector > OutConnectorPtr
const std::vector< std::string > & getComponents() const
Returns all components of the scope as an ordered list.
boost::shared_ptr< Participant > ParticipantPtr
std::vector< transport::InPullConnectorPtr > createInPullConnectors(const ParticipantConfig &config)
A derived Method class which can be called from the remote side and implements its behavior by invoki...
boost::shared_ptr< ConverterSelectionStrategy< WireType > > Ptr
boost::shared_ptr< IntlCallback > CallbackPtr
Description of a desired transport.
The server side of a request-reply-based communication channel.
void registerDefaultTransports()
boost::shared_ptr< SignalParticipantCreated > SignalParticipantCreatedPtr
Factory for RSB user-level domain objects for communication patterns.
A Listener receives events published by rsb::Informer objects by participating in a channel with a su...
A Reader receives events published by a informers by participating in a channel with a suitable scope...
Transport & mutableTransport(const std::string &name)
Returns a single configured transport which can be modified in place.
InformerBasePtr createInformerBase(const Scope &scope, const std::string &dataType="", const ParticipantConfig &config=getFactory().getDefaultParticipantConfig(), ParticipantPtr parent=ParticipantPtr())
Creates and returns a new Informer that publishes Event s under the Scope scope.
boost::shared_ptr< InPushConnector > InPushConnectorPtr
patterns::RemoteServer::RemoteMethodPtr createRemoteMethod(const Scope &scope, const ParticipantConfig &listenerConfig=getFactory().getDefaultParticipantConfig(), const ParticipantConfig &informerConfig=getFactory().getDefaultParticipantConfig(), ParticipantPtr parent=ParticipantPtr())
Creates a patterns::RemoteServer::RemoteMethod.
const std::string CONFIG_FILES_ENVIRONEMNT_VARIABLE
ParticipantConfig defaultConfig
Always acquire configMutex before reading or writing the config.
A class describing the configuration of Participant instances.
InPullFactory & getInPullFactory()
SignalParticipantCreatedPtr getSignalParticipantCreated()
ReaderPtr createReader(const Scope &scope, const ParticipantConfig &config=getFactory().getDefaultParticipantConfig(), ParticipantPtr parent=ParticipantPtr())
Creates a new Reader object for the specified scope.
void setDefaultParticipantConfig(const ParticipantConfig &config)
Sets the default config for participants that will be used for every new participant that is created ...
boost::shared_ptr< InformerBase > InformerBasePtr
SignalParticipantCreatedPtr signalParticipantCreated
InPushFactory & getInPushFactory()
boost::shared_ptr< RemoteServer > RemoteServerPtr
rsc::logging::LoggerPtr logger
OutFactory & getOutFactory()
void registerDefaultConverters()
rsc::plugins::ManagerPtr pluginManager
boost::recursive_mutex configMutex
patterns::LocalServer::LocalMethodPtr createLocalMethod(const Scope &scope, patterns::LocalServer::CallbackPtr callback, const ParticipantConfig &listenerConfig=getFactory().getDefaultParticipantConfig(), const ParticipantConfig &informerConfig=getFactory().getDefaultParticipantConfig(), ParticipantPtr parent=ParticipantPtr())
Creates a patterns::LocalServer::LocalMethod.
boost::shared_ptr< SignalParticipantDestroyed > SignalParticipantDestroyedPtr
boost::shared_ptr< InPullConnector > InPullConnectorPtr
Scope is a descriptor for a hierarchical channel of the unified bus.
std::set< Transport > getTransports(bool includeDisabled=false) const
Returns the set of desired transports for a participant.
rsc::plugins::ManagerPtr getPluginManager() const
Returns the plugin manager instance used by the RSB core.
patterns::RemoteServerPtr createRemoteServer(const Scope &scope, const ParticipantConfig &listenerConfig=getFactory().getDefaultParticipantConfig(), const ParticipantConfig &informerConfig=getFactory().getDefaultParticipantConfig(), ParticipantPtr parent=ParticipantPtr())
Creates a RemoteServer object for the server at scope scope.
Factory * factoryWhileLoadingPlugins
boost::signals2::signal< void(ParticipantPtr, ParticipantPtr)> SignalParticipantCreated
void setEnabled(bool value)
The client side of a request-reply-based communication channel.