36 for (
size_t i = 0;
i < header.
length();
i++) {
41 for (
size_t i = 0;
i < header.
length();
i++) {
42 char ch = header.
get()[
i];
54#ifndef DOXYGEN_SHOULD_SKIP_THIS
59 static std::mutex mutex;
61 std::vector<Carrier*> delegates;
63 Carrier* chooseCarrier(
const std::string& name,
76std::mutex Carriers::Private::mutex{};
78Carrier* Carriers::Private::chooseCarrier(
const std::string& name,
82 auto pos = name.find(
'+');
83 if (pos != std::string::npos) {
87 for (
auto& delegate : delegates) {
102 return Carriers::Private::chooseCarrier(name,
false);
107 "Could not find carrier \"%s\"",
108 (!name.empty()) ? name.c_str() :
"[bytes]");
113Carrier* Carriers::Private::chooseCarrier(
const Bytes& header,
116 for (
auto& delegate : delegates) {
118 if (
c.checkHeader(header)) {
126 return Carriers::Private::chooseCarrier(header,
false);
131 "Could not find carrier for a connection starting with: %s",
138bool Carriers::Private::matchCarrier(
const Bytes& header,
Bottle& code)
143 for (
size_t i = 0;
i < code.
size() && !done;
i++) {
148 if (header.
length() <= at) {
153 if (
j != header.
get()[at]) {
167bool Carriers::Private::checkForCarrier(
const Bytes& header,
Searchable& group)
170 if (code.
size() == 0) {
174 std::string name = group.
find(
"name").asString();
182bool Carriers::Private::scanForCarrier(
const Bytes& header)
188 for (
size_t i = 0;
i < lst.
size();
i++) {
196bool Carriers::Private::select(
Searchable& options)
198 return options.
check(
"type",
Value(
"none")).asString() ==
"carrier";
204Carriers::Carriers() :
210 mPriv->delegates.emplace_back(
new TcpCarrier());
211 mPriv->delegates.emplace_back(
new TcpCarrier(
false));
213 mPriv->delegates.emplace_back(
new UdpCarrier());
215 mPriv->delegates.emplace_back(
new TextCarrier(
true));
226 for (
auto& delegate : mPriv->delegates) {
230 mPriv->delegates.clear();
240 return getInstance().mPriv->chooseCarrier(name,
true,
true);
266 face =
c->createFace();
291 face =
c->createFace();
305 getInstance().mPriv->delegates.emplace_back(carrier);
320 std::lock_guard<std::mutex>
guard(Private::mutex);
325 std::vector<Carrier*>& delegates = instance.mPriv->delegates;
326 for (
auto& delegate : delegates) {
332 instance.mPriv->scan();
333 Bottle plugins = instance.mPriv->getSelectedPlugins();
334 for (
size_t i = 0;
i < plugins.
size();
i++) {
336 std::string name = options.
check(
"name",
Value(
"untitled")).asString();
337 if (done.
check(name)) {
A simple collection of objects that can be described and transmitted in a portable way.
size_type size() const
Gets the number of elements in the bottle.
Value & get(size_type index) const
Reads a Value v from a certain part of the list.
void addString(const char *str)
Places a string in the bottle, at the end of the list.
A mini-server for performing network communication in the background.
std::string getName() const override
Get name of port.
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
void write(bool forceStrict=false)
Write the current object being returned by BufferedPort::prepare.
A simple abstraction for a block of bytes.
A base class for connection types (tcp, mcast, shmem, ...) which are called carriers in YARP.
Collection of carriers, a singleton.
static Bottle listCarriers()
static Face * listen(const Contact &address)
Create a "proto-carrier" interface object that waits for incoming connections prior to a carrier bein...
static Carrier * getCarrierTemplate(const std::string &name)
Get template for carrier.
static bool addCarrierPrototype(Carrier *carrier)
Add a new connection type.
static Carrier * chooseCarrier(const std::string &name)
Select a carrier by name.
static Carriers & getInstance()
static OutputProtocol * connect(const Contact &address)
Initiate a connection to an address.
virtual ~Carriers()
Destructor.
void clear()
Remove all carriers.
The initial point-of-contact with a port.
static bool registerCarrier(const char *name, const char *dll)
Register a carrier to make available at runtime.
The output side of an active connection between two ports.
A class for storing options and configuration information.
void put(const std::string &key, const std::string &value)
Associate the given key with the given string.
bool check(const std::string &key) const override
Check if there exists a property of the given name.
A base class for nested structures that can be searched.
virtual bool check(const std::string &key) const =0
Check if there exists a property of the given name.
virtual Value & find(const std::string &key) const =0
Gets a value corresponding to a given keyword.
virtual Bottle & findGroup(const std::string &key) const =0
Gets a list corresponding to a given keyword.
A wrapper for a named factory method in a named shared library.
std::string getName() const
Get the name associated with this factory.
A single value (typically within a Bottle).
virtual bool isString() const
Checks if value is a string.
bool check(const std::string &key) const override
Check if there exists a property of the given name.
virtual std::string asString() const
Get string value.
Pick out a set of relevant plugins.
Bottle getSelectedPlugins() const
void scan()
Find plugin configuration files, and run [plugin] sections through the select method.
virtual bool select(Searchable &options)
Determine whether a plugin is of interest.
Collect hints for finding a particular plugin.
bool setSelector(YarpPluginSelector &selector)
Use a selector to find a plugin or plugins.
bool open(SharedLibraryFactory &factory)
Initialize a factory object based on the hints available.
bool readFromSearchable(Searchable &options, const std::string &name)
Configure settings from a configuration file or other searchable object.
A dummy Face for testing purposes.
A carrier for communicating locally within a process.
Communicating between two ports via MCAST.
Communicating between two ports via a variant plain-text protocol originally designed for the yarp na...
Communicating between two ports via TCP.
Communicating with a port via TCP.
Communicating between two ports via a plain-text protocol.
Communicating between two ports via UDP.
#define yCError(component,...)
#define yCDebug(component,...)
#define YARP_OS_LOG_COMPONENT(name, name_string)
std::string to_string(IntegerType x)
The components from which ports and connections are built.
An interface to the operating system, including Port based communication.