bool CipherFileIO::writeOneBlock(const IORequest &req) { if (haveHeader && fsConfig->reverseEncryption) { rDebug("writing to a reverse mount with per-file IVs is not implemented"); return -EROFS; } int bs = blockSize(); off_t blockNum = req.offset / bs; if (haveHeader && fileIV == 0) initHeader(); bool ok; if (req.dataLen != bs) { ok = streamWrite(req.data, (int)req.dataLen, blockNum ^ fileIV); } else { ok = blockWrite(req.data, (int)req.dataLen, blockNum ^ fileIV); } if (ok) { if (haveHeader) { IORequest tmpReq = req; tmpReq.offset += HEADER_SIZE; ok = base->write(tmpReq); } else ok = base->write(req); } else { rDebug("encodeBlock failed for block %" PRIi64 ", size %i", blockNum, req.dataLen); ok = false; } return ok; }
/** * Read block from backing ciphertext file, decrypt it (normal mode) * or * Read block from backing plaintext file, then encrypt it (reverse mode) */ ssize_t CipherFileIO::readOneBlock(const IORequest &req) const { int bs = blockSize(); off_t blockNum = req.offset / bs; ssize_t readSize = 0; IORequest tmpReq = req; // adjust offset if we have a file header if (haveHeader && !fsConfig->reverseEncryption) { tmpReq.offset += HEADER_SIZE; } readSize = base->read(tmpReq); bool ok; if (readSize > 0) { if (haveHeader && fileIV == 0) const_cast<CipherFileIO *>(this)->initHeader(); if (readSize != bs) { rDebug("streamRead(data, %d, IV)", (int)readSize); ok = streamRead(tmpReq.data, (int)readSize, blockNum ^ fileIV); } else { ok = blockRead(tmpReq.data, (int)readSize, blockNum ^ fileIV); } if (!ok) { rDebug("decodeBlock failed for block %" PRIi64 ", size %i", blockNum, (int)readSize); readSize = -1; } } else rDebug("readSize zero for offset %" PRIi64, req.offset); return readSize; }
bool CipherFileIO::writeHeader() { if (!base->isWritable()) { // open for write.. int newFlags = lastFlags | O_RDWR; if (base->open(newFlags) < 0) { rDebug("writeHeader failed to re-open for write"); return false; } } if (fileIV == 0) rError("Internal error: fileIV == 0 in writeHeader!!!"); rDebug("writing fileIV %" PRIu64, fileIV); unsigned char buf[8] = {0}; for (int i = 0; i < 8; ++i) { buf[sizeof(buf) - 1 - i] = (unsigned char)(fileIV & 0xff); fileIV >>= 8; } cipher->streamEncode(buf, sizeof(buf), externalIV, key); IORequest req; req.offset = 0; req.data = buf; req.dataLen = 8; base->write(req); return true; }
Chaine TypeTemplate::Afficher() const { rDebug("TypeTemplate::Afficher") ; Chaine resultat(NomComplet(this->espaceDeNom)) ; rDebug("TypeTemplate::Afficher 2") ; Chaine sortieParametres ; // if (parametres) // sortieParametres = (parametres->ToString()) ; for(IterateurListeComposition<ParametreTemplate> parametre(this->_parametres) ; parametre.Valide() ; ++parametre) { sortieParametres += ',' ; sortieParametres += parametre->Afficher() ; rDebug("parametre = " + parametre->Afficher()) ; } rDebug("fin TypeTemplate::Afficher") ; return "template " + resultat + Chaine("::") + classeTemplate->Name()->ToString() + "<" + sortieParametres +">" ; }
ssize_t Memory::write(const char *buf, size_t size, off_t offset) { rDebug("Memory::write(%s) | m_FileSize: 0x%lx, size: 0x%lx, offset: 0x%lx", m_name.c_str(), (long int) m_FileSize, (long int) size, (long int) offset); m_TimeSet = false; if ((m_FileSize == offset) && FileUtils::isZeroOnly(buf, size)) { rDebug("Memory::write(%s) | Full of zeroes only", m_name.c_str()); assert(m_FileSizeSet == true); assert(size > 0); m_FileSize = offset + size; } else { // Store buffer to memory in LinearMap. // if (m_LinearMap.put(buf, size, offset) == -1) return -1; assert(m_FileSizeSet == true); assert(size > 0); m_FileSize = max(m_FileSize, (off_t) (offset + size)); // Try to write a block to disk if appropriate. // int r = write(false); if (r == -1) return r; } return size; }
/*! Est capable de reconnaitre les templates préfixés par des namespaces, ainsi que ceux déjà identifiés comme des templates par opencxx. */ TypeTemplate* TypeTemplate::IdentifierTypeTemplate (TypeInfo informationType, Environment* environement) { rDebug("TypeTemplate::IdentifierTypeTemplate") ; switch(informationType.WhatIs()) { case TemplateType: { rDebug("whatis dit que c'ets un template") ; TemplateClass* classeTemplate = informationType.TemplateClassMetaobject() ; Base::Composition<TypeTemplate> resultat(new TypeTemplate(classeTemplate)) ; // arguments int nombreArguments = 0 ; TypeInfo typeArgument ; while(informationType.NthTemplateArgument(nombreArguments++,typeArgument)) { if (typeArgument.WhatIs() == UndefType) { rDebug("parametre n'a pas de type") ; } else resultat->_parametres.AjouterEnQueue(Type::Construire(typeArgument, environement)) ; } return resultat.Liberer() ; break ; } default: rDebug("whatis dit que c'ets autre chose") ; return NULL ; } }
///Local Component parameters read at start ///Reading parameters from config file or passed in command line, with Ice machinery ///We need to supply a list of accepted values to each call void SpecificMonitor::readConfig(RoboCompCommonBehavior::ParameterList ¶ms ) { //Read params from config file //Example RoboCompCommonBehavior::Parameter aux; aux.editable = false; configGetString( "joystickUniversal.Device", aux.value,"/dev/input/js0"); params["joystickUniversal.Device"] = aux; aux.editable = false; configGetString( "joystickUniversal.NumAxes", aux.value,"2"); params["joystickUniversal.NumAxes"] = aux; aux.editable = false; configGetString( "joystickUniversal.NumButtons", aux.value,"1"); params["joystickUniversal.NumButtons"] = aux; aux.editable = false; configGetString( "joystickUniversal.BasicPeriod", aux.value,"100"); params["joystickUniversal.BasicPeriod"] = aux; aux.editable = false; configGetString( "joystickUniversal.NormalizationValue", aux.value,"10"); params["joystickUniversal.NormalizationValue"] = aux; aux.editable = false; configGetString( "joystickUniversal.VelocityAxis", aux.value,"vel"); params["joystickUniversal.VelocityAxis"] = aux; aux.editable = false; configGetString( "joystickUniversal.DirectionAxis", aux.value,"dir"); params["joystickUniversal.DirectionAxis"] = aux; for (int i=0; i < atoi(params.at("joystickUniversal.NumAxes").value.c_str()); i++) { aux.editable = false; std::string s = QString::number(i).toStdString(); configGetString( "joystickUniversal.Axis_" + s, aux.value , "4"); params["joystickUniversal.Axis_" + s] = aux; rDebug("joystickUniversal.Axis_"+QString::fromStdString(s)+" = " + QString::fromStdString(params.at("joystickUniversal.Axis_" + s).value)); QStringList list = QString::fromStdString(aux.value).split(","); if (list.size() != 4) qFatal("joystickUniversalComp::Monitor::readConfig(): ERROR reading axis. Only %d parameters for motor %d.", list.size(), i); aux.value=list[0].toStdString(); params["joystickUniversal.Axis_" + s +".Name"] = aux; rDebug("joystickUniversal.Axis_" + s + ".Name = " + params.at("joystickUniversal.Axis_" + s +".Name").value); aux.value=list[1].toStdString(); params["joystickUniversal.Axis_" + s +".MinRange"]= aux; rDebug("joystickUniversal.Axis_"+s+".MinRange = "+ params["joystickUniversal.Axis_" + s +".MinRange"].value); aux.value=list[2].toStdString(); params["joystickUniversal.Axis_" + s +".MaxRange"]= aux; rDebug("joystickUniversal.Axis_"+s+".MaxRange = "+ params["joystickUniversal.Axis_" + s +".MaxRange"].value); aux.value=list[3].toStdString(); params["joystickUniversal.Axis_" + s +".Inverted"]= aux; rDebug("joystickUniversal.Axis_"+s+".Inverted = "+ params["joystickUniversal.Axis_" + s +".Inverted"].value); } }
Compress::Compress(const struct stat *st, const char *name) : Parent (st, name) { if (st->st_size == 0) { // New empty file, default strategy // is to compress a file. // m_IsCompressed = true; // New empty file, will be compressed, // reserve space for a FileHeader. // m_RawFileSize = FileHeader::MaxSize; } else if (st->st_size < FileHeader::MinSize) { // Nonempty file with length smaller than minimal length of // the FileHeader has to be uncompressed. m_IsCompressed = false; } else { // This is a constructor, no one could // call the open() function yet. assert(m_fd == -1); try { restoreFileHeader(name); m_IsCompressed = m_fh.isValid(); if (m_IsCompressed) { m_RawFileSize = (m_fh.index == 0) ? FileHeader::MaxSize : st->st_size; } } catch (...) { m_IsCompressed = false; } } if (m_IsCompressed) { rDebug("C (%s), raw/user 0x%lx/0x%lx bytes", name, (long int) m_RawFileSize, (long int) m_fh.size); } else { rDebug("N (%s), 0x%lx bytes", name, (long int) st->st_size); } }
int do_fuse_loop(struct fuse *fs, bool mt) { if (!fs->ch.get() || fs->ch->mountpoint.empty()) return -1; //Calculate umasks int umask=fs->conf.umask; if (umask==0) umask=0777; //It's OCTAL! Really! int dirumask=fs->conf.dirumask; if (dirumask==0) dirumask=umask; int fileumask=fs->conf.fileumask; if (fileumask==0) fileumask=umask; impl_fuse_context impl(&fs->ops,fs->user_data, fs->conf.debug!=0, fileumask, dirumask, fs->conf.fsname, fs->conf.volname); //Parse Dokan options PDOKAN_OPTIONS dokanOptions = (PDOKAN_OPTIONS)malloc(sizeof(DOKAN_OPTIONS)); if (dokanOptions == NULL) { rDebug("dokanOptions == NULL"); return -1; } ZeroMemory(dokanOptions, sizeof(DOKAN_OPTIONS)); dokanOptions->Options |= DOKAN_OPTION_KEEP_ALIVE|DOKAN_OPTION_REMOVABLE; dokanOptions->GlobalContext = reinterpret_cast<ULONG64>(&impl); wchar_t mount[MAX_PATH+1]; mbstowcs(mount,fs->ch->mountpoint.c_str(),MAX_PATH); dokanOptions->Version = DOKAN_VERSION; dokanOptions->MountPoint = mount; dokanOptions->ThreadCount = mt?FUSE_THREAD_COUNT:1; //Debug if (fs->conf.debug) dokanOptions->Options |= DOKAN_OPTION_DEBUG|DOKAN_OPTION_STDERR; //Load Dokan DLL if (!fs->ch->init()) { rError("Couldn't load DLL."); return -1; //Couldn't load DLL. TODO: UGLY!! } //The main loop! fs->within_loop=true; int res=fs->ch->ResolvedDokanMain(dokanOptions, &dokanOperations); fs->within_loop=false; rDebug("res=%i", res); return res; }
void CipherFileIO::initHeader() { // check if the file has a header, and read it if it does.. Otherwise, // create one. off_t rawSize = base->getSize(); if (rawSize >= HEADER_SIZE) { rDebug("reading existing header, rawSize = %" PRIi64, rawSize); // has a header.. read it unsigned char buf[8] = {0}; IORequest req; req.offset = 0; req.data = buf; req.dataLen = 8; base->read(req); cipher->streamDecode(buf, sizeof(buf), externalIV, key); fileIV = 0; for (int i = 0; i < 8; ++i) fileIV = (fileIV << 8) | (uint64_t)buf[i]; rAssert(fileIV != 0); // 0 is never used.. } else { rDebug("creating new file IV header"); unsigned char buf[8] = {0}; do { if (!cipher->randomize(buf, 8, false)) throw ERROR("Unable to generate a random file IV"); fileIV = 0; for (int i = 0; i < 8; ++i) fileIV = (fileIV << 8) | (uint64_t)buf[i]; if (fileIV == 0) rWarning("Unexpected result: randomize returned 8 null bytes!"); } while (fileIV == 0); // don't accept 0 as an option.. if (base->isWritable()) { cipher->streamEncode(buf, sizeof(buf), externalIV, key); IORequest req; req.offset = 0; req.data = buf; req.dataLen = 8; base->write(req); } else rDebug("base not writable, IV not written.."); } rDebug("initHeader finished, fileIV = %" PRIu64, fileIV); }
int Compress::open(const char *name, int flags) { assert(m_name == name); int r; r = Parent::open(name, flags); if ((m_refs == 1) && m_IsCompressed && (m_fh.index != 0)) { try { restoreLayerMap(); } catch (...) { // TODO: Detect error and set 'errno' correctly. rError("%s: Failed to restore LayerMap of file '%s'", __PRETTY_FUNCTION__, name); // Failed to restore LayerMap althrought it should be present. Mark the file // as not compressed to pass following release() correctly. m_IsCompressed = false; release(name); errno = EIO; return -1; } } rDebug("Compress::open m_refs: %d", m_refs); return r; }
/** * \brief Kill component */ void GenericMonitor::killYourSelf() { rDebug("Killing myself"); worker->killYourSelf(); emit kill(); }
void Compress::storeLayerMap() { rDebug("%s: m_fd: %d", __PRETTY_FUNCTION__, m_fd); // Don't store LayerMap if it has not been modified // since begining (open). if (!m_lm.isModified()) return; io::nonclosable_file_descriptor file(m_fd); file.seek(m_RawFileSize, ios_base::beg); io::filtering_ostream out; m_fh.type.push(out); out.push(file); portable_binary_oarchive pba(out); pba << m_lm; // Set the file header's index to the current offset // where the index was saved. m_fh.index = m_RawFileSize; }
/** * \brief Kill component */ void Monitor::killYourSelf() { rDebug("Killing myself"); this->exit(); worker->killYourSelf(); emit kill(); }
/** * \brief Default constructor */ GenericWorker::GenericWorker(MapPrx& mprx) : #ifdef USE_QTGUI Ui_guiDlg() #else QObject() #endif { speechinform_proxy = (*(SpeechInformPrx*)mprx["SpeechInformPub"]); mutex = new QMutex(QMutex::Recursive); #ifdef USE_QTGUI setupUi(this); show(); #endif Period = BASIC_PERIOD; connect(&timer, SIGNAL(timeout()), this, SLOT(compute())); // timer.start(Period); } /** * \brief Default destructor */ GenericWorker::~GenericWorker() { } void GenericWorker::killYourSelf() { rDebug("Killing myself"); emit kill(); }
BaseTemplate TypeTemplate::TemplateDeBase() const { Chaine nom(this->classeTemplate->Name()->ToString()) ; rDebug(nom) ; if (nom == Chaine("Association")) return Compilateur::Association ; else if (nom == Chaine("Composition")) return Compilateur::Composition ; else if (nom == Chaine("EnsembleComposition")) return Compilateur::EnsembleComposition ; else if (nom == Chaine("EnsembleAssociation")) return Compilateur::EnsembleAssociation ; else if (nom == Chaine("FonctionObjetValeur")) return Compilateur::FonctionObjetValeur ; else if (nom == Chaine("FonctionCompositionObjetObjet")) return Compilateur::FonctionCompositionObjetObjet ; else if (nom == Chaine("FonctionAssociationObjetObjet")) return Compilateur::FonctionAssociationObjetObjet ; else if (nom == Chaine("FonctionCompositionValeurObjet")) return Compilateur::FonctionCompositionValeurObjet ; else if (nom == Chaine("FonctionAssociationValeurObjet")) return Compilateur::FonctionAssociationValeurObjet ; else return Compilateur::NonPrisEnCompte ; }
ssize_t Memory::readFullParent(char * &buf, size_t &len, off_t &offset) const { ssize_t r = Parent::read(buf, len, offset); rDebug("Memory::readFullParent(%s) | Parent::read(1) returned 0x%lx", m_name.c_str(), (long int) r); if (r == -1) return -1; buf += r; offset += r; len -= r; assert (m_FileSize >= offset); if (len > 0) { ssize_t tmp = min(m_FileSize - offset, (off_t) len); assert(tmp >= 0); assert(tmp <= len); memset(buf, 0, tmp); buf += tmp; offset += tmp; len -= tmp; } return 0; }
/** * \brief Default constructor */ GenericWorker::GenericWorker(MapPrx& mprx) : #ifdef USE_QTGUI Ui_guiDlg() #else QObject() #endif { innermodelmanager_proxy = (*(InnerModelManagerPrx*)mprx["InnerModelManagerProxy"]); jointmotor0_proxy = (*(JointMotorPrx*)mprx["JointMotor0Proxy"]); jointmotor1_proxy = (*(JointMotorPrx*)mprx["JointMotor1Proxy"]); differentialrobot_proxy = (*(DifferentialRobotPrx*)mprx["DifferentialRobotProxy"]); mutex = new QMutex(); #ifdef USE_QTGUI setupUi(this); show(); #endif Period = BASIC_PERIOD; connect(&timer, SIGNAL(timeout()), this, SLOT(compute())); } /** * \brief Default destructor */ GenericWorker::~GenericWorker() { } void GenericWorker::killYourSelf() { rDebug("Killing myself"); emit kill(); }
void qt_msg_handler(QtMsgType type, const char *msg) #endif { switch (type) { case QtDebugMsg: rDebug(QString("QtDebugMsg: %1").arg(msg)); break; case QtWarningMsg: rNotice(QString("QtWarningMsg: %1").arg(msg)); break; case QtCriticalMsg: rWarn(QString("QtCriticalMsg: %1").arg(msg)); break; case QtFatalMsg: rError(QString("QtFatalMsg: %1").arg(msg)); break; #if QT_VERSION >= QT_VERSION_CHECK (5, 5, 0) case QtInfoMsg: break; #endif } if (type == QtFatalMsg) { rError("Fatal Qt error. Aborting."); abort(); } }
/** * \brief Default constructor */ GenericWorker::GenericWorker(MapPrx& mprx) : #ifdef USE_QTGUI Ui_guiDlg() #else QObject() #endif { innermodelmanager_proxy = (*(InnerModelManagerPrx*)mprx["InnerModelManagerProxy"]); agmexecutive_proxy = (*(AGMExecutivePrx*)mprx["AGMExecutiveProxy"]); mutex = new QMutex(QMutex::Recursive); #ifdef USE_QTGUI setupUi(this); show(); #endif Period = BASIC_PERIOD; connect(&timer, SIGNAL(timeout()), this, SLOT(compute())); // timer.start(Period); } /** * \brief Default destructor */ GenericWorker::~GenericWorker() { } void GenericWorker::killYourSelf() { rDebug("Killing myself"); emit kill(); }
/** * \brief Default constructor */ GenericWorker::GenericWorker(MapPrx& mprx) : #ifdef USE_QTGUI Ui_guiDlg() #else QObject() #endif { inversekinematics_proxy = (*(InverseKinematicsPrx*)mprx["InverseKinematicsProxy"]); jointmotor_proxy = (*(JointMotorPrx*)mprx["JointMotorProxy"]); mutex = new QMutex(QMutex::Recursive); #ifdef USE_QTGUI setupUi(this); show(); #endif Period = BASIC_PERIOD; connect(&timer, SIGNAL(timeout()), this, SLOT(compute())); // timer.start(Period); } /** * \brief Default destructor */ GenericWorker::~GenericWorker() { } void GenericWorker::killYourSelf() { rDebug("Killing myself"); emit kill(); }
/// PRIVATE METHODS int CanBus::setBaudRate(int baudRate) { void * speed; switch(baudRate) { case 20000: speed=VSCAN_SPEED_20K; break; case 50000: speed=VSCAN_SPEED_50K; break; case 100000:speed=VSCAN_SPEED_100K; break; case 125000:speed=VSCAN_SPEED_125K; break; case 250000:speed=VSCAN_SPEED_250K; break; case 500000:speed=VSCAN_SPEED_500K; break; case 800000:speed=VSCAN_SPEED_800K; break; case 1000000:speed=VSCAN_SPEED_1M; break; default: rDebug("ERROR: "+QString::number(baudRate)+" no es un valor de baudRate válido (20000, 50000, 100000, 125000, 250000, 500000, 800000, 1000000)"); return -1; } char string[33]; int status = VSCAN_Ioctl(devHandler, VSCAN_IOCTL_SET_SPEED, VSCAN_SPEED_1M); VSCAN_GetErrorString(status,string,32); printf(" Apertura puerto %s\n",string); status = VSCAN_Ioctl(devHandler, VSCAN_IOCTL_SET_TIMESTAMP, VSCAN_TIMESTAMP_ON); VSCAN_GetErrorString(status,string,32); printf(" SET TIME STAMP %s\n",string); return status; }
/** * \brief Default constructor */ CanBus::CanBus(QString device, int baudRate) { printf("CanBus::CanBus: %s %d\n", device.toStdString().c_str(), baudRate); rDebug("CanBus initialize"); // Open and initialize the device devHandler = VSCAN_Open(device.toAscii().data(), VSCAN_MODE_NORMAL); if(devHandler < 0) { qFatal("Failed to open Can device "); return; } rDebug("Can device "+device+" oppened correctly"); if(setBaudRate(baudRate) != 0) rDebug("Failed setting baudRate"); }
/** * \brief Default constructor */ GenericWorker::GenericWorker(MapPrx& mprx) : #ifdef USE_QTGUI Ui_guiDlg() #else QObject() #endif { rgbd_proxy = (*(RGBDPrx*)mprx["RGBDProxy"]); mutex = new QMutex(); #ifdef USE_QTGUI setupUi(this); show(); #endif Period = BASIC_PERIOD; connect(&timer, SIGNAL(timeout()), this, SLOT(compute())); } /** * \brief Default destructor */ GenericWorker::~GenericWorker() { } void GenericWorker::killYourSelf() { rDebug("Killing myself"); emit kill(); }
bool CipherFileIO::streamWrite(unsigned char *buf, int size, uint64_t _iv64) const { rDebug("Called streamWrite"); if (!fsConfig->reverseEncryption) return cipher->streamEncode(buf, size, _iv64, key); else return cipher->streamDecode(buf, size, _iv64, key); }
TypeTemplate* TypeTemplate::Construire(Opencxx::TypeInfo& informationType, Environment* environement) { rDebug("TypeTemplate::Construire = "+informationType.WhatIs()) ; return IdentifierTypeTemplate(informationType, environement) ; }
bool PlayerHandler::executeSpeed(float adv,float rot) { // posIface->data->cmdVelocity.pos.x = adv/1000.; // posIface->data->cmdVelocity.yaw = rot; pos->SetSpeed(adv/1000,-rot); rDebug("execute speed "); return true; }
/** * \brief Thread method */ void Monitor::run() { initialize(); forever { rDebug("monitor run"); this->sleep(500); } }
struct fuse *fuse_setup(int argc, char *argv[], const struct fuse_operations *op, size_t op_size, char **mountpoint, int *multithreaded, void *user_data) { struct fuse_args args = FUSE_ARGS_INIT(argc, argv); struct fuse_chan *ch=NULL; struct fuse *fuse; int foreground; int res; res = fuse_parse_cmdline(&args, mountpoint, multithreaded, &foreground); rDebug("res=%i", res); if (res == -1) return NULL; ch = fuse_mount(*mountpoint, &args); fuse = fuse_new(ch, &args, op, op_size, user_data); fuse_opt_free_args(&args); if (fuse == NULL || ch==NULL) goto err_unmount; res = fuse_daemonize(foreground); rDebug("res=%i", res); if (res == -1) goto err_unmount; if (fuse->conf.setsignals) { res = fuse_set_signal_handlers(fuse_get_session(fuse)); rDebug("res=%i", res); if (res == -1) goto err_unmount; } return fuse; err_unmount: fuse_unmount(*mountpoint, ch); if (fuse) fuse_destroy(fuse); free(*mountpoint); return NULL; }
void Namespace::ensureNoConflicts(const scene::INodePtr& root) { // Instantiate a new, temporary namespace for the nodes below root Namespace foreignNamespace; // Move all nodes below (and including) root into this temporary namespace foreignNamespace.connect(root); // Collect all namespaced items from the foreign root GatherNamespacedWalker walker; root->traverse(walker); rDebug() << "Namespace::ensureNoConflicts(): imported set of " << walker.result.size() << " namespaced nodes" << std::endl; // Build a union set containing all imported names and all existing names. // We need to know all existing names to ensure that newly created names are // unique in *both* namespaces UniqueNameSet allNames = _uniqueNames; allNames.merge(foreignNamespace._uniqueNames); // Process each object in the to-be-imported tree of nodes, ensuring that it // has a unique name for (const NamespacedPtr& n : walker.result) { // If the imported node conflicts with a name in THIS namespace, then it // needs to be given a new name which is unique in BOTH namespaces. if (_uniqueNames.nameExists(n->getName())) { // Name exists in the target namespace, get a new name std::string uniqueName = allNames.insertUnique(n->getName()); rMessage() << "Namespace::ensureNoConflicts(): '" << n->getName() << "' already exists in this namespace. Rename it to '" << uniqueName << "'\n"; // Change the name of the imported node, this should trigger all // observers in the foreign namespace n->changeName(uniqueName); } else { // Name does not exist yet, insert it into the local combined // namespace (but not our destination namespace, this will be // populated in the subsequent call to connect()). allNames.insert(n->getName()); } } // at this point, all names in the foreign namespace have been converted to // something unique in this namespace. The calling code can now move the // nodes into this namespace without name conflicts // Disconnect the root from the foreign namespace again, it will be destroyed now foreignNamespace.disconnect(root); }