YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
yarpconfig.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
6#include <yarp/os/Property.h>
7#include <yarp/os/Network.h>
8#include <yarp/conf/version.h>
9#include <yarp/os/Time.h>
11#include "yarpcontext.h"
12#include "yarprobot.h"
13#include <cstdio>
14#include <cstring>
15
16void show_help() {
17 printf("Usage: yarp-config [OPTION]\n\n");
18 printf("Known values for OPTION are:\n\n");
19 printf(" --help display this help and exit\n");
20 printf(" --version report version information\n");
21 printf(" --namespace report file that caches the current YARP namespace\n");
22 printf(" --nameserver report file that caches nameserver contact information\n");
23 printf("\n");
26}
27
28int main(int argc, char *argv[]) {
29 // Configure system clock
31
32 yarp::os::Property options;
33 options.fromCommand(argc,argv);
34 if (options.check("help")) {
35 show_help();
36 return 0;
37 }
38 if (argc>=2) {
39 if (!strcmp(argv[1],"context")) {
40 return yarp_context_main(argc,argv);
41 }
42 if (!strcmp(argv[1],"robot")) {
43 return yarp_robot_main(argc,argv);
44 }
45 }
46 if (options.check("version")) {
47 printf("%s\n", YARP_VERSION);
48 return 0;
49 }
50 if (options.check("namespace")) {
52 printf("%s\n",nc.getConfigFileName(YARP_CONFIG_NAMESPACE_FILENAME).c_str());
53 return 0;
54 }
55 if (options.check("nameserver")) {
57 printf("%s\n",nc.getConfigFileName().c_str());
58 return 0;
59 }
60 show_help();
61 return 1;
62}
#define YARP_CONFIG_NAMESPACE_FILENAME
Definition NameConfig.h:16
static void initMinimum()
Basic system initialization, not including plugins.
Definition Network.cpp:871
A class for storing options and configuration information.
Definition Property.h:33
bool check(const std::string &key) const override
Check if there exists a property of the given name.
void fromCommand(int argc, char *argv[], bool skipFirst=true, bool wipe=true)
Interprets a list of command arguments as a list of properties.
Small helper class to help deal with legacy YARP configuration files.
Definition NameConfig.h:23
std::string getConfigFileName(const char *stem=nullptr, const char *ns=nullptr)
@ YARP_CLOCK_SYSTEM
Definition Time.h:28
#define YARP_VERSION
Definition version.h:14
int main(int argc, char *argv[])
void show_help()
void yarp_context_help()
int yarp_context_main(int argc, char *argv[])
int yarp_robot_main(int argc, char *argv[])
Definition yarprobot.cpp:35
void yarp_robot_help()
Definition yarprobot.cpp:18