本文整理汇总了C++中ConstString类的典型用法代码示例。如果您正苦于以下问题:C++ ConstString类的具体用法?C++ ConstString怎么用?C++ ConstString使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ConstString类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: locker
size_t
ModuleList::FindFunctions (const ConstString &name,
uint32_t name_type_mask,
bool include_symbols,
bool include_inlines,
bool append,
SymbolContextList &sc_list) const
{
if (!append)
sc_list.Clear();
const size_t old_size = sc_list.GetSize();
if (name_type_mask & eFunctionNameTypeAuto)
{
ConstString lookup_name;
uint32_t lookup_name_type_mask = 0;
bool match_name_after_lookup = false;
Module::PrepareForFunctionNameLookup (name, name_type_mask,
lookup_name,
lookup_name_type_mask,
match_name_after_lookup);
Mutex::Locker locker(m_modules_mutex);
collection::const_iterator pos, end = m_modules.end();
for (pos = m_modules.begin(); pos != end; ++pos)
{
(*pos)->FindFunctions (lookup_name,
NULL,
lookup_name_type_mask,
include_symbols,
include_inlines,
true,
sc_list);
}
if (match_name_after_lookup)
{
SymbolContext sc;
size_t i = old_size;
while (i<sc_list.GetSize())
{
if (sc_list.GetContextAtIndex(i, sc))
{
const char *func_name = sc.GetFunctionName().GetCString();
if (func_name && strstr (func_name, name.GetCString()) == NULL)
{
// Remove the current context
sc_list.RemoveContextAtIndex(i);
// Don't increment i and continue in the loop
continue;
}
}
++i;
}
}
}
else
{
Mutex::Locker locker(m_modules_mutex);
collection::const_iterator pos, end = m_modules.end();
for (pos = m_modules.begin(); pos != end; ++pos)
{
(*pos)->FindFunctions (name, NULL, name_type_mask, include_symbols, include_inlines, true, sc_list);
}
}
return sc_list.GetSize() - old_size;
}
示例2: open
virtual bool open(Searchable &s)
{
Time::turboBoost();
// get command line options
options.fromString(s.toString());
if (!options.check("robot") || !options.check("part"))
{
printf("Missing either --robot or --part options. Quitting!\n");
return false;
}
// get command file options
Value& robot = options.find("robot");
Value& part = options.find("part");
configFileRobotPart = "config_";
configFileRobotPart = configFileRobotPart + robot.asString();
configFileRobotPart = configFileRobotPart + "_";
configFileRobotPart = configFileRobotPart + part.asString();
configFileRobotPart = configFileRobotPart + ".ini";
//get the joints to be dumped
getRate(options, rate);
fprintf(stderr, "Selected rate is: %d\n", rate);
if (getNumberUsedJoints(options, nJoints) == 0)
return false;
thetaMap = new int[nJoints];
if (getUsedJointsMap(options, nJoints, thetaMap) == 0)
return false;
//get the type of data to be dumped
if (getNumberDataToDump(options, nData) == 0)
return false;
dataToDump = new ConstString[nData];
if (getDataToDump(options, dataToDump, nData) == 0)
return false;
for (int i = 0; i < nData; i++)
fprintf(stderr, "%s \n", dataToDump[i].c_str());
//if (!fileOptions.check("d"))
// {
// fprintf(stderr, "Missing option 'd' in given config file\n");
// return 1;
// }
//Value& d = fileOptions.find("d");
//open remote control board
ddBoardOptions.put("device", "remote_controlboard");
ddDebugOptions.put("device", "debugInterfaceClient");
ConstString localPortName = name;
ConstString localDebugPortName = name;
localPortName = localPortName + "/controlBoardDumper/";
localDebugPortName = localPortName + "debug/";
//localPortName = localPortName + robot.asString();
localPortName = localPortName + part.asString();
localDebugPortName = localDebugPortName + part.asString();
ddBoardOptions.put("local", localPortName.c_str());
ddDebugOptions.put("local", localDebugPortName.c_str());
ConstString remotePortName = "/";
remotePortName = remotePortName + robot.asString();
remotePortName = remotePortName + "/";
remotePortName = remotePortName + part.asString();
ddBoardOptions.put("remote", remotePortName.c_str());
ddDebugOptions.put("remote", remotePortName.c_str());
fprintf(stderr, "%s", ddBoardOptions.toString().c_str());
// create a device
ddBoard.open(ddBoardOptions);
if (!ddBoard.isValid()) {
printf("Device not available. Here are the known devices:\n");
printf("%s", Drivers::factory().toString().c_str());
Network::fini();
return false;
}
ddDebug.open(ddDebugOptions);
if (!ddDebug.isValid()) {
printf("Debug Interface is mandatary to run this module. Here are the known devices:\n");
printf("%s", Drivers::factory().toString().c_str());
Network::fini();
return false;
}
bool logToFile = false;
if (options.check("logToFile")) logToFile = true;
portPrefix = "/";
portPrefix= portPrefix + "controlBoardDumper/" + part.asString() + "/";
//boardDumperThread *myDumper = new boardDumperThread(&dd, rate, portPrefix, dataToDump[0]);
//myDumper->setThetaMap(thetaMap, nJoints);
//.........这里部分代码省略.........
示例3: suggest
int NameServer::main(int argc, char *argv[]) {
//Network yarp;
// pick an address
Contact suggest("...",0); // suggestion is initially empty
ConstString nameSpace = "";
if (argc>=1) {
if (argv[0][0]=='/') {
nameSpace = argv[0];
// BUT: not used yet
argv++;
argc--;
}
if (argc>=2) {
suggest = Contact(argv[0],NetType::toInt(argv[1]));
} else if (argc>=1) {
suggest = Contact("...",NetType::toInt(argv[0]));
}
}
Property config;
config.fromCommand(argc,argv,false);
bool bNoAuto=config.check("noauto");
// see what address is lying around
Contact prev;
NameConfig conf;
if (nameSpace!="") {
conf.setNamespace(nameSpace.c_str());
}
if (conf.fromFile()) {
prev = conf.getAddress();
}
else if (bNoAuto)
{
YARP_ERROR(Logger::get(), ConstString("Could not find configuration file ") +
conf.getConfigFileName());
return 1;
}
// merge
if (prev.isValid()) {
if (suggest.getHost()=="...") {
suggest = Contact(prev.getHost(),suggest.getPort());
}
if (suggest.getPort()==0) {
suggest = Contact(suggest.getHost(),prev.getPort());
}
}
// still something not set?
if (suggest.getPort()==0) {
suggest = Contact(suggest.getHost(),NetworkBase::getDefaultPortRange());
}
if (suggest.getHost()=="...") {
// should get my IP
suggest = Contact(conf.getHostName(),suggest.getPort());
}
// finally, should make sure IP is local, and if not, correct it
if (!conf.isLocalName(suggest.getHost())) {
YARP_INFO(Logger::get(),"Overriding non-local address for name server");
suggest = Contact(conf.getHostName(),suggest.getPort());
}
// and save
conf.setAddress(suggest);
if (!conf.toFile()) {
YARP_ERROR(Logger::get(), ConstString("Could not save configuration file ") +
conf.getConfigFileName());
}
MainNameServer name(suggest.getPort() + 2);
// register root for documentation purposes
name.registerName(conf.getNamespace(),suggest);
Port server;
name.setPort(server);
server.setReaderCreator(name);
suggest.setName(conf.getNamespace());
bool ok = server.open(suggest, false);
if (ok) {
YARP_DEBUG(Logger::get(), ConstString("Name server listening at ") +
suggest.toURI());
YARP_SPRINTF2(Logger::get(),info,
"Name server can be browsed at http://%s:%d/",
suggest.getHost().c_str(), suggest.getPort());
#ifdef YARP_HAS_ACE
FallbackNameServer fallback(name);
fallback.start();
// register fallback root for documentation purposes
name.registerName("fallback",FallbackNameServer::getAddress());
YARP_INFO(Logger::get(), ConstString("Bootstrap server listening at ") +
//.........这里部分代码省略.........
示例4: convert
bool ConverterEngine::convert( const ConstString & _converter, const ConstString & _category, const ConstString & _in, ConstString & _out )
{
ConverterInterfacePtr converter = this->createConverter( _converter );
if ( converter == nullptr )
{
LOGGER_ERROR(m_serviceProvider)("ConverterEngine::convert: can't create converter '%s'"
, _converter.c_str()
);
return false;
}
ConverterOptions options;
options.pakName = _category;
options.inputFileName = _in;
if( FILE_SERVICE(m_serviceProvider)
->hasFileGroup( _category, nullptr ) == false )
{
LOGGER_ERROR(m_serviceProvider)("ConverterEngine::convert: can't get file system '%s' for converter '%s'"
, _category.c_str()
, _converter.c_str()
);
return false;
}
PathString cache_path;
cache_path += _in;
cache_path.cut_before_last_of( '.' );
const String & ext = converter->getConvertExt();
cache_path += ext;
options.outputFileName = Helper::stringizeString( m_serviceProvider, cache_path );
converter->setOptions( &options );
if( options.inputFileName.empty() == true )
{
LOGGER_ERROR(m_serviceProvider)("ConverterEngine::convert input file is empty"
);
return false;
}
if( options.outputFileName.empty() == true )
{
LOGGER_ERROR(m_serviceProvider)("ConverterEngine::convert output file is empty"
);
return false;
}
if( FILE_SERVICE(m_serviceProvider)
->existFile( options.pakName, options.inputFileName, nullptr ) == false )
{
LOGGER_ERROR(m_serviceProvider)("ConverterEngine::convert: input file '%s:%s' not found"
, options.pakName.c_str()
, options.inputFileName.c_str()
);
return false;
}
if( FILE_SERVICE(m_serviceProvider)
->existFile( options.pakName, options.outputFileName, nullptr ) == true )
{
InputStreamInterfacePtr oldFile = FILE_SERVICE(m_serviceProvider)
->openInputFile( options.pakName, options.inputFileName, false );
if( oldFile == nullptr )
{
LOGGER_ERROR(m_serviceProvider)("ConverterEngine::convert '%s' can't open input file '%s:%s' (time)"
, _converter.c_str()
, options.pakName.c_str()
, options.inputFileName.c_str()
);
return false;
}
uint64_t fileTimeInput;
oldFile->time( fileTimeInput );
oldFile = nullptr;
InputStreamInterfacePtr newFile = FILE_SERVICE(m_serviceProvider)
->openInputFile( options.pakName, options.outputFileName, false );
if( newFile == nullptr )
{
LOGGER_ERROR(m_serviceProvider)("ConverterEngine::convert '%s' can't open output file '%s:%s' (time)"
, _converter.c_str()
, options.pakName.c_str()
, options.outputFileName.c_str()
//.........这里部分代码省略.........
示例5: main
int main(int argc, char *argv[]) {
Property p;
p.fromCommand(argc,argv);
// To make sure that the dev test are able to find all the devices
// compile by YARP, also the one compiled as dynamic plugins
// we add the build directory to the YARP_DATA_DIRS enviromental variable
// CMAKE_CURRENT_DIR is the define by the CMakeLists.txt tests file
ConstString dirs = CMAKE_BINARY_DIR +
yarp::os::Network::getDirectorySeparator() +
"share" +
yarp::os::Network::getDirectorySeparator() +
"yarp";
// Add TEST_DATA_DIR to YARP_DATA_DIRS in order to find the contexts used
// by the tests
dirs += yarp::os::Network::getPathSeparator() +
TEST_DATA_DIR;
// If set, append user YARP_DATA_DIRS
// FIXME check if this can be removed
Network::getEnvironment("YARP_DATA_DIRS");
if (!Network::getEnvironment("YARP_DATA_DIRS").empty()) {
dirs += yarp::os::Network::getPathSeparator() +
Network::getEnvironment("YARP_DATA_DIRS");
}
Network::setEnvironment("YARP_DATA_DIRS", dirs);
printf("YARP_DATA_DIRS=\"%s\"\n", Network::getEnvironment("YARP_DATA_DIRS").c_str());
// check where to put description of device
ConstString dest = "";
dest = p.check("doc",Value("")).toString();
ConstString fileName = p.check("file",Value("default.ini")).asString();
if (p.check("file")) {
p.fromConfigFile(fileName);
}
ConstString deviceName = p.check("device",Value("")).asString();
// if no device given, we should be operating a completely
// standard test harness like for libYARP_OS and libYARP_sig
if (deviceName=="") {
return harness_main(argc,argv);
}
// device name given - use special device testing procedure
#ifdef CHECK_FOR_LEAKS
mtrace();
#endif
int result = 0;
Network::init();
Network::setLocalMode(true);
ConstString seek = fileName.c_str();
ConstString exampleName = "";
int pos = seek.rfind('/');
if (pos==-1) {
pos = seek.rfind('\\');
}
if (pos==-1) {
pos = 0;
} else {
pos++;
}
int len = seek.find('.',pos);
if (len==-1) {
len = seek.length();
} else {
len -= pos;
}
exampleName = seek.substr(pos,len).c_str();
ConstString shortFileName = seek.substr(pos,seek.length()).c_str();
PolyDriver dd;
YARP_DEBUG(Logger::get(), "harness opening...");
bool ok = dd.open(p);
YARP_DEBUG(Logger::get(), "harness opened.");
result = ok?0:1;
ConstString wrapperName = "";
ConstString codeName = "";
DriverCreator *creator =
Drivers::factory().find(deviceName.c_str());
if (creator!=nullptr) {
wrapperName = creator->getWrapper();
codeName = creator->getCode();
}
if (dest!="") {
ConstString dest2 = dest.c_str();
if (result!=0) {
//.........这里部分代码省略.........
示例6: switch
bool
Host::GetLLDBPath (PathType path_type, FileSpec &file_spec)
{
// To get paths related to LLDB we get the path to the executable that
// contains this function. On MacOSX this will be "LLDB.framework/.../LLDB",
// on linux this is assumed to be the "lldb" main executable. If LLDB on
// linux is actually in a shared library (lldb.so??) then this function will
// need to be modified to "do the right thing".
switch (path_type)
{
case ePathTypeLLDBShlibDir:
{
static ConstString g_lldb_so_dir;
if (!g_lldb_so_dir)
{
FileSpec lldb_file_spec (Host::GetModuleFileSpecForHostAddress ((void *)Host::GetLLDBPath));
g_lldb_so_dir = lldb_file_spec.GetDirectory();
}
file_spec.GetDirectory() = g_lldb_so_dir;
return file_spec.GetDirectory();
}
break;
case ePathTypeSupportExecutableDir:
{
static ConstString g_lldb_support_exe_dir;
if (!g_lldb_support_exe_dir)
{
FileSpec lldb_file_spec;
if (GetLLDBPath (ePathTypeLLDBShlibDir, lldb_file_spec))
{
char raw_path[PATH_MAX];
char resolved_path[PATH_MAX];
lldb_file_spec.GetPath(raw_path, sizeof(raw_path));
#if defined (__APPLE__)
char *framework_pos = ::strstr (raw_path, "LLDB.framework");
if (framework_pos)
{
framework_pos += strlen("LLDB.framework");
#if !defined (__arm__)
::strncpy (framework_pos, "/Resources", PATH_MAX - (framework_pos - raw_path));
#endif
}
#endif
FileSpec::Resolve (raw_path, resolved_path, sizeof(resolved_path));
g_lldb_support_exe_dir.SetCString(resolved_path);
}
}
file_spec.GetDirectory() = g_lldb_support_exe_dir;
return file_spec.GetDirectory();
}
break;
case ePathTypeHeaderDir:
{
static ConstString g_lldb_headers_dir;
if (!g_lldb_headers_dir)
{
#if defined (__APPLE__)
FileSpec lldb_file_spec;
if (GetLLDBPath (ePathTypeLLDBShlibDir, lldb_file_spec))
{
char raw_path[PATH_MAX];
char resolved_path[PATH_MAX];
lldb_file_spec.GetPath(raw_path, sizeof(raw_path));
char *framework_pos = ::strstr (raw_path, "LLDB.framework");
if (framework_pos)
{
framework_pos += strlen("LLDB.framework");
::strncpy (framework_pos, "/Headers", PATH_MAX - (framework_pos - raw_path));
}
FileSpec::Resolve (raw_path, resolved_path, sizeof(resolved_path));
g_lldb_headers_dir.SetCString(resolved_path);
}
#else
// TODO: Anyone know how we can determine this for linux? Other systems??
g_lldb_headers_dir.SetCString ("/opt/local/include/lldb");
#endif
}
file_spec.GetDirectory() = g_lldb_headers_dir;
return file_spec.GetDirectory();
}
break;
case ePathTypePythonDir:
{
// TODO: Anyone know how we can determine this for linux? Other systems?
// For linux and FreeBSD we are currently assuming the
// location of the lldb binary that contains this function is
// the directory that will contain a python directory which
// has our lldb module. This is how files get placed when
// compiling with Makefiles.
static ConstString g_lldb_python_dir;
if (!g_lldb_python_dir)
{
FileSpec lldb_file_spec;
//.........这里部分代码省略.........
示例7: yAssert
void Image::wrapIplImage(void *iplImage) {
yAssert(iplImage!=NULL);
IplImage *p = (IplImage *)iplImage;
ConstString str = p->colorModel;
int code = -1;
int color_code = -1;
if (str=="rgb"||str=="RGB"||
str=="bgr"||str=="BGR"||
str=="gray"||str=="GRAY"||
str=="graygray"||str=="GRAYGRAY") {
str = p->channelSeq;
if (str=="rgb"||str=="RGB") {
color_code = VOCAB_PIXEL_RGB;
} else if (str=="bgr"||str=="BGR") {
color_code = VOCAB_PIXEL_BGR;
} else if (str=="gray"||str=="GRAY"||
str=="graygray"||str=="GRAYGRAY") {
color_code = VOCAB_PIXEL_MONO;
} else {
printf("specific IPL RGB order (%s) is not yet supported\n",
str.c_str());
printf("Try RGB, BGR, or \n");
printf("Or fix code at %s line %d\n",__FILE__,__LINE__);
exit(1);
}
}
// Type translation is approximate. Patches welcome to flesh out
// the types available.
if (p->depth == IPL_DEPTH_8U) {
code = color_code;
} else if (p->depth == IPL_DEPTH_8S) {
switch (color_code) {
case VOCAB_PIXEL_MONO:
code = VOCAB_PIXEL_MONO_SIGNED;
break;
case VOCAB_PIXEL_RGB:
code = VOCAB_PIXEL_RGB_SIGNED;
break;
case VOCAB_PIXEL_BGR:
code = color_code; // nothing better available
break;
}
} else if (p->depth == IPL_DEPTH_16U || p->depth == IPL_DEPTH_16S) {
switch (color_code) {
case VOCAB_PIXEL_MONO:
code = VOCAB_PIXEL_MONO16;
break;
case VOCAB_PIXEL_RGB:
case VOCAB_PIXEL_BGR:
fprintf(stderr,"No translation currently available for this pixel type\n");
exit(1);
break;
}
} else if (p->depth == IPL_DEPTH_32S) {
switch (color_code) {
case VOCAB_PIXEL_MONO:
code = VOCAB_PIXEL_INT;
break;
case VOCAB_PIXEL_RGB:
case VOCAB_PIXEL_BGR:
code = VOCAB_PIXEL_RGB_INT;
break;
}
} else if (p->depth == IPL_DEPTH_32F) {
switch (color_code) {
case VOCAB_PIXEL_MONO:
code = VOCAB_PIXEL_MONO_FLOAT;
break;
case VOCAB_PIXEL_RGB:
case VOCAB_PIXEL_BGR:
code = VOCAB_PIXEL_RGB_FLOAT;
break;
}
}
if (code==-1) {
fprintf(stderr,"IPL pixel type / depth combination is not yet supported\n");
fprintf(stderr,"Please email a YARP developer to complain, quoting this:\n");
fprintf(stderr," %s:%d\n", __FILE__, __LINE__);
}
if (getPixelCode()!=code && getPixelCode()!=-1) {
printf("your specific IPL format (%s depth %d -> %s) does not match your YARP format (%s)\n",
str.c_str(),
p->depth,
Vocab::decode(code).c_str(),
Vocab::decode(getPixelCode()).c_str());
printf("Making a copy instead of just wrapping...\n");
FlexImage img;
img.setQuantum(p->align);
img.setPixelCode(code);
img.setExternal(p->imageData,p->width,p->height);
copy(img);
} else {
setQuantum(p->align);
setPixelCode(code);
setExternal(p->imageData,p->width,p->height);
}
}
示例8: read
bool file::read(ImageOf<PixelRgb> & dest, const ConstString& src)
{
return ImageReadRGB(dest,src.c_str());
}
示例9: Value
bool SalienceModule::configure(yarp::os::ResourceFinder &rf){
ConstString str = rf.check("name", Value("/salience"), "module name (string)").asString();
setName(str.c_str()); // modulePortName
attachTerminal();
// framerate
_intFPS = rf.check("fps", Value(20), "Try to achieve this number of frames per second (int).").asInt();
_intPrintFPSAfterNumFrames = rf.check("fpsOutputFrequency", Value(20), "Print the achieved framerate after this number of frames (int).").asInt();
_dblTPF = 1.0f/((float)_intFPS);
_intFPSAchieved = 0;
_intFC = 0;
_dblTPFAchieved = 0.0;
_dblStartTime = 0.0;
numBlurPasses = rf.check("numBlurPasses",
Value(0),
"Blur the output map numBlurPasses times with a gaussian 3x3 kernel (int).").asInt();
drawSaliencePeak = (bool)rf.check("drawSaliencePeak",
Value(1),
"Draw a crosshair at salience peak onto the output visualization image (int [0|1]).").asInt();
thresholdSalience = rf.check("thresholdSalience",
Value(0.0),
"Set salience map values < threshold to zero (double).").asDouble();
activateIOR = (bool)rf.check("activateInhibitionOfReturn",
Value(0),
"Use IOR (int [0|1]).").asInt();
if (activateIOR){
ior.open(rf);
}
filter = NULL;
ConstString filterName = rf.check("filter",
Value(""),
"filter to use (string [group|intensity|color|directional|motion|emd|ruddy|face])").asString();
if (filterName=="") {
printf("*** Please specify a filter, e.g. --filter motion\n");
vector<string> names = SalienceFactories::getPool().getNames();
printf("*** Filters available: ");
for (unsigned int i=0; i<names.size(); i++) {
printf("%s ", names[i].c_str());
}
printf("\n");
return false;
}
filter = SalienceFactories::getPool().get(filterName);
if (filter!=NULL) {
bool ok = filter->open(rf);
if (!ok) {
delete filter;
filter = NULL;
return false;
}
}
imgPort.open(getName("/view"));
peakPort.open(getName("/peak")); //For streaming saliency peak coordinates (Alex, 31/05/08)
filteredPort.open(getName("/map"));
configPort.open(getName("/conf"));
attach(configPort);
oldSizeX = -1;
oldSizeY = -1;
needInit = true;
fflush(stdout);
return true;
}
示例10: Add
void Add(ConstString &type_name, ConstString &type_equivalent) {
m_impl.Insert(type_name.GetStringRef(), type_equivalent);
}
示例11: bot
bool PolyDriver::coreOpen(yarp::os::Searchable& prop) {
yarp::os::Searchable *config = ∝
Property p;
ConstString str = prop.toString();
Value *part;
if (prop.check("device",part)) {
str = part->toString().c_str();
}
Bottle bot(str.c_str());
if (bot.size()>1) {
// this wasn't a device name, but some codes -- rearrange
p.fromString(str.c_str());
str = p.find("device").asString().c_str();
config = &p;
}
DeviceDriver *driver = NULL;
DriverCreator *creator = Drivers::factory().find(str.c_str());
if (creator!=NULL) {
Value *val;
if (config->check("wrapped",val)&&(creator->getWrapper()!="")) {
ConstString wrapper = creator->getWrapper();
DriverCreator *wrapCreator =
Drivers::factory().find(wrapper.c_str());
if (wrapCreator!=NULL) {
p.fromString(config->toString());
p.unput("wrapped");
config = &p;
if (wrapCreator!=creator) {
p.put("subdevice",str.c_str());
p.put("device",wrapper.c_str());
p.setMonitor(prop.getMonitor(),
wrapper.c_str()); // pass on any monitoring
driver = wrapCreator->create();
creator = wrapCreator;
} else {
// already wrapped
driver = creator->create();
}
}
} else {
driver = creator->create();
}
} else {
printf("yarpdev: ***ERROR*** could not find device <%s>\n", str.c_str());
}
if (driver!=NULL) {
PolyDriver *manager = creator->owner();
if (manager!=NULL) {
link(*manager);
return true;
}
//printf("yarpdev: parameters are %s\n", config->toString().c_str());
bool ok = driver->open(*config);
if (!ok) {
printf("yarpdev: ***ERROR*** driver <%s> was found but could not open\n", config->find("device").toString().c_str());
//YARP_DEBUG(Logger::get(),String("Discarding ") + str);
delete driver;
//YARP_DEBUG(Logger::get(),String("Discarded ") + str);
driver = NULL;
} else {
yarp::dev::DeprecatedDeviceDriver *ddd = NULL;
driver->view(ddd);
if(ddd) {
if(config->check("allow-deprecated-devices")) {
yWarning("Device \"%s\" is deprecated. Opening since the \"allow-deprecated-devices\" option was passed in the configuration.", str.c_str());
} else {
yError("Device \"%s\" is deprecated. Pass the \"allow-deprecated-devices\" option in the configuration if you want to open it anyway.", str.c_str());
driver->close();
return false;
}
}
if (creator!=NULL) {
ConstString name = creator->getName();
ConstString wrapper = creator->getWrapper();
ConstString code = creator->getCode();
yInfo("created %s <%s>. See C++ class %s for documentation.",
((name==wrapper)?"wrapper":"device"),
name.c_str(),
code.c_str());
}
}
dd = driver;
return true;
}
return false;
}
示例12: YARP_ERROR
bool Port::open(const Contact& contact, bool registerName,
const char *fakeName)
{
Contact contact2 = contact;
if (!NetworkBase::initialized()) {
YARP_ERROR(Logger::get(), "YARP not initialized; create a yarp::os::Network object before using ports");
return false;
}
ConstString n = contact2.getName();
NameConfig conf;
ConstString nenv = ConstString("YARP_RENAME") + conf.getSafeString(n);
ConstString rename = NetworkBase::getEnvironment(nenv.c_str());
if (rename!="") {
n = rename;
contact2.setName(n);
}
bool local = false;
if (n == "" && contact2.getPort()<=0) {
local = true;
registerName = false;
n = "...";
}
NestedContact nc(n);
if (nc.getNestedName()!="") {
if (nc.getNodeName() == "") {
Nodes& nodes = NameClient::getNameClient().getNodes();
nodes.requireActiveName();
ConstString node_name = nodes.getActiveName();
if (node_name!="") {
n = n + node_name;
}
}
}
PortCoreAdapter *currentCore = &(IMPL());
if (currentCore!=nullptr) {
currentCore->active = false;
if (n!="" && (n[0]!='/'||currentCore->includeNode) && n[0]!='=' && n!="..." && n.substr(0, 3)!="...") {
if (fakeName==nullptr) {
Nodes& nodes = NameClient::getNameClient().getNodes();
ConstString node_name = nodes.getActiveName();
if (node_name!="") {
n = (n[0]=='/'?"":"/") + n + "@" + node_name;
}
}
}
}
if (n!="" && n[0]!='/' && n[0]!='=' && n!="..." && n.substr(0, 3)!="...") {
if (fakeName==nullptr) {
YARP_SPRINTF1(Logger::get(), error,
"Port name '%s' needs to start with a '/' character",
n.c_str());
return false;
}
}
if (n!="" && n!="..." && n[0]!='=' && n.substr(0, 3)!="...") {
if (fakeName==nullptr) {
ConstString prefix = NetworkBase::getEnvironment("YARP_PORT_PREFIX");
if (prefix!="") {
n = prefix + n;
contact2.setName(n);
}
}
}
if (currentCore!=nullptr) {
NestedContact nc;
nc.fromString(n);
if (nc.getNestedName()!="") {
if (nc.getCategory()=="") {
// we need to add in a category
ConstString cat = "";
if (currentCore->commitToRead) {
cat = "-";
} else if (currentCore->commitToWrite) {
cat = "+";
}
if (cat!="") {
if (currentCore->commitToRpc) {
cat += "1";
}
contact2.setName(nc.getNestedName() +
cat +
"@" +
nc.getNodeName());
} else {
YARP_SPRINTF1(Logger::get(), error,
"Error: Port '%s' is not committed to being either an input or output port.",
n.c_str());
YARP_SPRINTF0(Logger::get(), error,
"YARP does not mind, but we are trying to register with a name server that does.");
YARP_SPRINTF0(Logger::get(), error,
"You can call Port::setWriteOnly() or Port::setReadOnly(), OR rename the port.");
NestedContact nc2 = nc;
nc2.setCategoryWrite();
YARP_SPRINTF1(Logger::get(), error,
//.........这里部分代码省略.........
示例13: perror
String NameConfig::getHostName(bool prefer_loopback, String seed) {
// try to pick a good host identifier
ConstString result = "127.0.0.1";
bool loopback = true;
bool found = false;
// Pick an IPv4 address.
// Prefer non-local addresses, then seed, then shorter addresses.
// Avoid IPv6.
#ifdef YARP_HAS_ACE
ACE_INET_Addr *ips = NULL;
size_t count = 0;
if (ACE::get_ip_interfaces(count,ips)>=0) {
for (size_t i=0; i<count; i++) {
ConstString ip = ips[i].get_host_addr();
#else
int family, s;
char hostname[NI_MAXHOST]; hostname[NI_MAXHOST-1] = '\0';
ConstString ip;
struct ifaddrs *ifaddr, *ifa;
if (getifaddrs(&ifaddr) == -1) {
perror("getifaddrs in getIps");
exit(EXIT_FAILURE);
}
for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) {
if (ifa->ifa_addr == NULL) continue;
family = ifa->ifa_addr->sa_family;
if (family == AF_INET || family == AF_INET6) {
s = getnameinfo(ifa->ifa_addr,
(family == AF_INET) ? sizeof(struct sockaddr_in) :
sizeof(struct sockaddr_in6),
hostname, NI_MAXHOST, NULL, 0, NI_NUMERICHOST);
if (s != 0) {
printf("getnameinfo() failed: %s\n", gai_strerror(s));
exit(EXIT_FAILURE);
}
ip = ConstString(hostname);
#endif
YARP_DEBUG(Logger::get(), String("scanning network interface ") +
ip.c_str());
if (ip.find(":")!=ConstString::npos) continue;
bool would_be_loopback = false;
if (ip == "127.0.0.1" || ip == "127.1.0.1" ||
ip == "127.0.1.1") {
would_be_loopback = true;
}
#ifdef YARP_HAS_ACE
#ifdef ACE_ADDR_HAS_LOOPBACK_METHOD
would_be_loopback = ips[i].is_loopback();
#endif
#endif
// If we haven't any interface yet, take this one
if (!found) {
result = ip;
loopback = would_be_loopback;
found = true;
continue;
}
// We have an interface
// If this isn't the right kind of interface, skip it
if (would_be_loopback != prefer_loopback) continue;
// This is the right kind of interface
// If we haven't the right kind of interface yet, take it
if (prefer_loopback != loopback) {
result = ip;
loopback = would_be_loopback;
continue;
}
// If it matches the seed interface, take it
if (ip==seed) {
result = ip;
loopback = would_be_loopback;
continue;
}
// If it is shorter, and what we have isn't the seed, take it
if (ip.length()<result.length() && result!=seed) {
result = ip;
loopback = would_be_loopback;
continue;
}
}
#ifdef YARP_HAS_ACE
delete[] ips;
#endif
}
return result.c_str();
}
//.........这里部分代码省略.........
示例14: openFake
bool Port::openFake(const ConstString& name) {
return open(Contact::byName(name),false,name.c_str());
}
示例15: write
bool file::write(const ImageOf<PixelRgba> & src, const ConstString& dest)
{
ImageOf<PixelRgb> img2;
img2.copy(src);
return ImageWriteRGB(const_cast<ImageOf<PixelRgb> &>(img2), dest.c_str());
}