23#define MIN_PORT_NUMBER_OFFSET 2
24#define MAX_PORT_NUMBER_OFFSET 9999
71 Network::registerContact(c);
77 std::string dbDefault =
":memory:";
78 std::string subdbDefault =
":memory:";
80 if (options.
check(
"memory")) {
81 yCWarning(NAMESERVERCONTAINER,
"The --memory option was given, but that is now a default. Continuing.");
84 std::string dbFilename = options.
check(
"portdb",
85 Value(dbDefault)).asString();
86 std::string subdbFilename = options.
check(
"subdb",
87 Value(subdbDefault)).asString();
89 std::string ip = options.
check(
"ip",
Value(
"...")).asString();
90 int sock = options.
check(
"socket",
Value(Network::getDefaultPortRange())).asInt32();
91 bool cautious = options.
check(
"cautious");
93 yCInfo(NAMESERVERCONTAINER,
"Using port database: %s", dbFilename.c_str());
94 yCInfo(NAMESERVERCONTAINER,
"Using subscription database: %s", subdbFilename.c_str());
95 if (dbFilename!=
":memory:" || subdbFilename!=
":memory:") {
96 yCInfo(NAMESERVERCONTAINER,
"If you ever need to clear the name server's state, just delete those files.");
98 yCInfo(NAMESERVERCONTAINER,
"IP address: %s", (ip==
"...")?
"default":ip.c_str());
99 yCInfo(NAMESERVERCONTAINER,
"Port number: %d", sock);
102 if (options.
check(
"ip")||options.
check(
"socket")) {
103 yCInfo(NAMESERVERCONTAINER,
"Database needs to be reset, IP or port number set.");
108 if (pmem ==
nullptr) {
109 yCError(NAMESERVERCONTAINER,
"Aborting, ports database failed to open.");
113 if (!subscriber.
open(subdbFilename)) {
114 yCError(NAMESERVERCONTAINER,
"Aborting, subscription database failed to open.");
118 contact =
Contact(
"...",
"tcp", ip, sock);
120 if (!options.
check(
"local")) {
121 if (!BootstrapServer::configFileBootstrap(contact,
122 options.
check(
"read"),
123 options.
check(
"write"))) {
124 yCError(NAMESERVERCONTAINER,
"Aborting.\n");
132 if (lstStr.find(
"rossrv") == std::string::npos ||
133 lstStr.find(
"tcpros") == std::string::npos ||
134 lstStr.find(
"xmlrpc") == std::string::npos) {
135 yCError(NAMESERVERCONTAINER,
"Missing one or more required carriers ");
136 yCError(NAMESERVERCONTAINER,
"for yarpserver --ros (rossrv, tcpros, xmlrpc).\n");
137 yCError(NAMESERVERCONTAINER,
"Run 'yarp connect --list-carriers' to see carriers on your machine\n");
138 yCError(NAMESERVERCONTAINER,
"Aborting.\n");
142 Contact c = Contact::fromString(addr);
149 yCInfo(NAMESERVERCONTAINER,
"Using ROS with ROS_MASTER_URI=%s\n", addr.c_str());
151 yCFatal(NAMESERVERCONTAINER,
"Cannot find ROS, check ROS_MASTER_URI (currently '%s')\n", addr.c_str());
157 alloc.
open(pmem,config);
158 ns.
open(pmem,&alloc,contact);
159 NetworkBase::queryBypass(&ns);
163 combo1.
open(subscriber,style);
#define MAX_PORT_NUMBER_OFFSET
#define MIN_PORT_NUMBER_OFFSET
Multicast and file-based mechanisms for finding the name server.
A simple collection of objects that can be described and transmitted in a portable way.
std::string toString() const override
Gives a human-readable textual representation of the bottle.
Collection of carriers, a singleton.
static Bottle listCarriers()
An abstract name space for ports.
virtual Contact getNameServerContact() const =0
Get an address for a name server that manages the name space, if available.
Utilities for manipulating the YARP network, excluding initialization and shutdown.
Utilities for manipulating the YARP network, including initialization and shutdown.
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.
A single value (typically within a Bottle).
void open(TripleSource *db, const AllocatorConfig &config)
Compose two name services into one.
void open(NameService &ns1, NameService &ns2)
bool open(yarp::os::Searchable &options)
yarp::os::Contact whereDelegate()
~NameServerContainer() override
const yarp::os::Contact & where()
void preregister(const yarp::os::Contact &c)
An implementation of name service operators on a triple store.
void setDelegate(yarp::os::NameSpace *delegate)
void open(TripleSource *db, Allocator *alloc, const yarp::os::Contact &serverContact)
void setSubscriber(Subscriber *subscriber)
bool configure(const yarp::os::Searchable &options)
bool open(const std::string &filename, bool fresh=false)
bool welcome(const std::string &port, int activity) override
void setDelegate(yarp::os::NameSpace *delegate)
void setStore(yarp::os::NameStore &store)
TripleSource * open(const char *filename, bool cautious=false, bool fresh=false)
Abstract view of a database as a collection of triples.
#define yCInfo(component,...)
#define yCError(component,...)
#define yCWarning(component,...)
#define yCFatal(component,...)
#define YARP_SERVERSQL_LOG_COMPONENT(name, name_string)
std::string get_string(const std::string &key, bool *found=nullptr)
Read a string from an environment variable.