Commit 8d8de61d authored by Pavel Vainerman's avatar Pavel Vainerman

Удалил лишнюю сущность ObjectRepositoryFactory, перенёс его функциональность

в класс ObjectRepository.
parent 24d1baff
......@@ -9,7 +9,6 @@
// --------------------------------------------------------------------------
#include "ORepHelpers.h"
#include "ObjectRepository.h"
#include "ObjectRepositoryFactory.h"
#include "Exceptions.h"
#include "UniSetObject.h"
#include "UniSetTypes.h"
......@@ -523,7 +522,7 @@ static bool commandToAll(const string& section, std::shared_ptr<ObjectRepository
// ==============================================================================================
static void createSections( const std::shared_ptr<UniSetTypes::Configuration>& rconf )
{
ObjectRepositoryFactory repf(rconf);
ObjectRepository repf(rconf);
repf.createRootSection(rconf->getRootSection());
repf.createRootSection(rconf->getSensorsSection());
......
......@@ -86,13 +86,32 @@ class ObjectRepository
};
//! Получение списка how_many объектов из секции section.
bool list(const std::string& section, UniSetTypes::ListObjectName* ls, unsigned int how_many = 300)throw(UniSetTypes::ORepFailed);
bool list(const std::string& section, UniSetTypes::ListObjectName* ls, size_t how_many = 300)throw(UniSetTypes::ORepFailed);
//! Получние списка how_many подсекций из секции in_section.
bool listSections(const std::string& in_section, UniSetTypes::ListObjectName* ls, unsigned int how_many = 300)throw(UniSetTypes::ORepFailed);
bool listSections(const std::string& in_section, UniSetTypes::ListObjectName* ls, size_t how_many = 300)throw(UniSetTypes::ORepFailed);
// -------------------------------------------------------------------
//! Создание секции
bool createSection( const std::string& name, const std::string& in_section )throw(UniSetTypes::ORepFailed, UniSetTypes::InvalidObjectName);
/*! Создание секции по полному имени */
bool createSectionF(const std::string& fullName)throw(UniSetTypes::ORepFailed, UniSetTypes::InvalidObjectName);
//! Функция создания секции в корневом 'каталоге'
bool createRootSection(const std::string& name);
//! Функция удаления секции
bool removeSection(const std::string& fullName, bool recursive = false);
//! Функция переименования секции
bool renameSection(const std::string& newName, const std::string& fullName);
/*! Функция выводящая на экран список всех объектов расположенных в данной секции */
void printSection(const std::string& fullName);
// @}
// end of ORepServiceGroup
// end of add to ORepServiceGroup
protected:
......@@ -102,6 +121,9 @@ class ObjectRepository
bool list(const std::string& section, UniSetTypes::ListObjectName* ls, unsigned int how_many, ObjectType type);
/*! Создание нового контекста(секции) */
bool createContext( const std::string& cname, CosNaming::NamingContext_ptr ctx);
private:
bool init() const;
mutable CosNaming::NamingContext_var localctx;
......
/*
* Copyright (c) 2015 Pavel Vainerman.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, version 2.1.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Lesser Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// --------------------------------------------------------------------------
/*! \file
* \brief Интерфейсный класс для создания структуры репозитария объектов
* \author Pavel Vainerman
*/
// --------------------------------------------------------------------------
#ifndef ObjectRepositoryFactory_H_
#define ObjectRepositoryFactory_H_
// --------------------------------------------------------------------------
#include <omniORB4/CORBA.h>
#include <omniORB4/Naming.hh>
#include "Exceptions.h"
#include "ObjectRepository.h"
// -----------------------------------------------------------------------------------------
//namespase ORepositoryFacotry
//{
/*!\class ObjectRepositoryFactory */
class ObjectRepositoryFactory: private ObjectRepository
{
public:
ObjectRepositoryFactory( const std::shared_ptr<UniSetTypes::Configuration>& conf );
~ObjectRepositoryFactory();
//! Создание секции
bool createSection(const std::string& name, const std::string& in_section)throw(UniSetTypes::ORepFailed, UniSetTypes::InvalidObjectName);
/*! Создание секции по полному имени */
bool createSectionF(const std::string& fullName)throw(UniSetTypes::ORepFailed, UniSetTypes::InvalidObjectName);
//! Функция создания секции в корневом 'каталоге'
bool createRootSection(const std::string& name);
//! Функция удаления секции
bool removeSection(const std::string& fullName, bool recursive = false);
//! Функция переименования секции
bool renameSection(const std::string& newName, const std::string& fullName);
/**
@addtogroup ORepServiceGroup
@{
*/
/*! Функция выводящая на экран список всех объектов расположенных в данной секции */
void printSection(const std::string& fullName);
// void printSection(CosNaming::NamingContext_ptr ctx);
// @}
// end of add to ORepServiceGroup
protected:
private:
/*! Создание нового контекста(секции) */
bool createContext( const std::string& cname, CosNaming::NamingContext_ptr ctx);
};
//};
#endif
......@@ -2,7 +2,7 @@ noinst_LTLIBRARIES = libObjectsRepository.la
libObjectsRepository_la_SOURCES = UniSetTypes_iSK.cc UniSetObject_iSK.cc UniSetTypes.cc \
UniSetManager_iSK.cc ObjectIndex.cc ObjectIndex_Array.cc ObjectIndex_XML.cc ObjectIndex_idXML.cc \
ORepHelpers.cc UniSetObject.cc UniSetManager.cc \
UniSetActivator.cc ObjectRepository.cc ObjectRepositoryFactory.cc \
UniSetActivator.cc ObjectRepository.cc \
ProxyManager.cc PassiveObject.cc IORFile.cc
# ServiceActivator.cc
......
......@@ -308,7 +308,7 @@ throw(ORepFailed, NameNotFound)
* количество объектов в этой секции превышает заданное how_many.
* \exception ORepFailed - генерируется если произошла при получении доступа к секции
*/
bool ObjectRepository::list(const string& section, ListObjectName* ls, unsigned int how_many)throw(ORepFailed)
bool ObjectRepository::list(const string& section, ListObjectName* ls, size_t how_many)throw(ORepFailed)
{
return list(section, ls, how_many, ObjectRef);
}
......@@ -322,7 +322,7 @@ bool ObjectRepository::list(const string& section, ListObjectName* ls, unsigned
* количество объектов в этой секции превышает заданное how_many.
* \exception ORepFailed - генерируется если произошла при получении доступа к секции
*/
bool ObjectRepository::listSections(const string& in_section, ListObjectName* ls, unsigned int how_many)throw(ORepFailed)
bool ObjectRepository::listSections(const string& in_section, ListObjectName* ls, size_t how_many)throw(ORepFailed)
{
return list(in_section, ls, how_many, Section);
}
......@@ -444,3 +444,289 @@ bool ObjectRepository::isExist( const ObjectPtr& oref ) const
}
// --------------------------------------------------------------------------
/*!
* \param name - имя создаваемой секции
* \param in_section - полное имя секции внутри которой создается новая
* \param section - полное имя секции начиная с Root.
* \exception ORepFailed - генерируется если произошла при получении доступа к секции
*/
bool ObjectRepository::createSection(const string& name, const string& in_section)throw(ORepFailed, InvalidObjectName)
{
char bad = ORepHelpers::checkBadSymbols(name);
if (bad != 0)
{
ostringstream err;
err << "ObjectRepository(registration): (InvalidObjectName) " << name;
err << " содержит недопустимый символ " << bad;
throw ( InvalidObjectName(err.str().c_str()) );
}
ulogrep << "CreateSection: name = " << name << " in section = " << in_section << endl;
if( in_section.empty() )
{
ulogrep << "CreateSection: in_section..empty" << endl;
return createRootSection(name);
}
int argc(uconf->getArgc());
const char* const* argv(uconf->getArgv());
CosNaming::NamingContext_var ctx = ORepHelpers::getContext(in_section, argc, argv, uconf->getNSName() );
return createContext( name, ctx.in() );
}
// -------------------------------------------------------------------------------------------------------
/*!
* \param fullName - полное имя создаваемой секции
* \exception ORepFailed - генерируется если произошла при получении доступа к секции
*/
bool ObjectRepository::createSectionF( const string& fullName )throw(ORepFailed, InvalidObjectName)
{
string name(ObjectIndex::getBaseName(fullName));
string sec(ORepHelpers::getSectionName(fullName));
ulogrep << name << endl;
ulogrep << sec << endl;
if ( sec.empty() )
{
ulogrep << "SectionName is empty!!!" << endl;
ulogrep << "Добавляем в " << uconf->getRootSection() << endl;
return createSection(name, uconf->getRootSection());
}
else
return createSection(name, sec);
}
// ---------------------------------------------------------------------------------------------------------------
bool ObjectRepository::createRootSection( const string& name )
{
CORBA::ORB_var orb = uconf->getORB();
CosNaming::NamingContext_var ctx = ORepHelpers::getRootNamingContext(orb, uconf->getNSName());
return createContext(name, ctx);
}
// -----------------------------------------------------------------------------------------------------------
bool ObjectRepository::createContext( const string& cname, CosNaming::NamingContext_ptr ctx )
{
CosNaming::Name_var nc = omniURI::stringToName(cname.c_str());
try
{
ulogrep << "ORepFactory(createContext): создаю новый контекст " << cname << endl;
ctx->bind_new_context(nc);
ulogrep << "ORepFactory(createContext): создал. " << endl;
return true;
}
catch(const CosNaming::NamingContext::AlreadyBound& ab)
{
// ctx->resolve(nc);
ulogrep << "ORepFactory(createContext): context " << cname << " уже есть" << endl;
return true;
}
catch( const CosNaming::NamingContext::NotFound )
{
ulogrep << "ORepFactory(createContext): NotFound " << cname << endl;
throw NameNotFound();
}
catch( const CosNaming::NamingContext::InvalidName& nf )
{
uwarn << "ORepFactory(createContext): (InvalidName) " << cname;
}
catch( const CosNaming::NamingContext::CannotProceed& cp )
{
uwarn << "ORepFactory(createContext): catch CannotProced "
<< cname << " bad part="
<< omniURI::nameToString(cp.rest_of_name);
throw NameNotFound();
}
catch( const CORBA::SystemException& ex )
{
ucrit << "ORepFactory(createContext): CORBA::SystemException: "
<< ex.NP_minorString() << endl;
}
catch( const CORBA::Exception& )
{
ucrit << "поймали CORBA::Exception." << endl;
}
catch( const omniORB::fatalException& fe )
{
ucrit << "поймали omniORB::fatalException:" << endl;
ucrit << " file: " << fe.file() << endl;
ucrit << " line: " << fe.line() << endl;
ucrit << " mesg: " << fe.errmsg() << endl;
}
return false;
}
// -----------------------------------------------------------------------------------------------------------
/*!
\note Функция не вывести список, если не сможет получить доступ к секции
*/
void ObjectRepository::printSection( const string& fullName )
{
ListObjectName ls;
try
{
list(fullName.c_str(), &ls);
if( ls.empty() )
cout << fullName << " пуст!!!" << endl;
}
catch( ORepFailed )
{
cout << "printSection: cath exceptions ORepFailed..." << endl;
return ;
}
cout << fullName << "(" << ls.size() << "):" << endl;
for( auto v : ls )
cout << v << endl;
}
// -----------------------------------------------------------------------------------------------------------
/*!
* \param fullName - имя удаляемой секции
* \param recursive - удлаять рекурсивно все секции или возвращать не удалять и ошибку ( временно )
* \warning Функция вынимает только первые 1000 объектов, остальные игнорируются...
*/
bool ObjectRepository::removeSection(const string& fullName, bool recursive)
{
// string name = getName(fullName.c_str(),'/');
// string sec = getSectionName(fullName.c_str(),'/');
// CosNaming::NamingContext_var ctx = getContext(sec, argc, argv);
unsigned int how_many = 1000;
CosNaming::NamingContext_var ctx;
try
{
int argc(uconf->getArgc());
const char* const* argv(uconf->getArgv());
ctx = ORepHelpers::getContext(fullName, argc, argv, nsName);
}
catch( ORepFailed )
{
return false;
}
CosNaming::BindingList_var bl;
CosNaming::BindingIterator_var bi;
ctx->list(how_many, bl, bi);
// хитрая проверка на null приобращении к bl
// coverity говорит потенциально это возможно
// т.к. там возвращается указатель, который по умолчанию null
if( !bl.operator->() )
return false;
if( how_many > bl->length() )
how_many = bl->length();
bool rem = true; // удалять или нет
for(unsigned int i = 0; i < how_many; i++)
{
if( bl[i].binding_type == CosNaming::nobject)
{
// cout <<"удаляем "<< omniURI::nameToString(bl[i].binding_name) << endl;
ctx->unbind(bl[i].binding_name);
}
else if( bl[i].binding_type == CosNaming::ncontext)
{
if( recursive )
{
ulogrep << "ORepFactory: удаляем рекурсивно..." << endl;
string rctx = fullName + "/" + omniURI::nameToString(bl[i].binding_name);
ulogrep << rctx << endl;
if ( !removeSection(rctx))
{
ulogrep << "рекурсивно удалить не удалось" << endl;
rem = false;
}
}
else
{
ulogrep << "ORepFactory: " << omniURI::nameToString(bl[i].binding_name) << " - контекст!!! ";
ulogrep << "ORepFactory: пока не удаляем" << endl;
rem = false;
}
}
}
// Удаляем контекст, если он уже пустой
if( rem )
{
// Получаем имя контекста содержащего удаляемый
string in_sec(ORepHelpers::getSectionName(fullName));
//Получаем имя удаляемого контекста
string name(ObjectIndex::getBaseName(fullName));
try
{
int argc(uconf->getArgc());
const char* const* argv(uconf->getArgv());
CosNaming::Name_var ctxName = omniURI::stringToName(name.c_str());
CosNaming::NamingContext_var in_ctx = ORepHelpers::getContext(in_sec, argc, argv, nsName);
ctx->destroy();
in_ctx->unbind(ctxName);
}
catch(const CosNaming::NamingContext::NotEmpty& ne)
{
ulogrep << "ORepFactory: контекст" << fullName << " не пустой " << endl;
rem = false;
}
catch( ORepFailed )
{
ulogrep << "ORepFactory: не удаось получить ссылку на контекст " << in_sec << endl;
rem = false;
}
}
if( !CORBA::is_nil(bi) )
bi->destroy(); // ??
return rem;
}
// -----------------------------------------------------------------------------------------------------------
/*!
* \param newFName - полное имя новой секции
* \param oldFName - полное имя удаляемрй секции
*/
bool ObjectRepository::renameSection( const string& newFName, const string& oldFName )
{
string newName(ObjectIndex::getBaseName(newFName));
string oldName(ObjectIndex::getBaseName(oldFName));
CosNaming::Name_var ctxNewName = omniURI::stringToName(newName.c_str());
CosNaming::Name_var ctxOldName = omniURI::stringToName(oldName.c_str());
string in_sec(ORepHelpers::getSectionName(newFName));
try
{
int argc(uconf->getArgc());
const char* const* argv(uconf->getArgv());
CosNaming::NamingContext_var in_ctx = ORepHelpers::getContext(in_sec, argc, argv, nsName);
CosNaming::NamingContext_var ctx = ORepHelpers::getContext(oldFName, argc, argv, nsName);
// заменит контекст newFName если он существовал
in_ctx->rebind_context(ctxNewName, ctx);
in_ctx->unbind(ctxOldName);
}
catch( ORepFailed )
{
return false;
}
return true;
}
// -----------------------------------------------------------------------------------------------------------
/*
* Copyright (c) 2015 Pavel Vainerman.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, version 2.1.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Lesser Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// --------------------------------------------------------------------------
/*! \file
* \author Pavel Vainerman
*/
// --------------------------------------------------------------------------
#include <omniORB4/CORBA.h>
#include <omniORB4/omniURI.h>
#include <string.h>
#include <sstream>
#include "ObjectRepositoryFactory.h"
#include "ORepHelpers.h"
#include "Configuration.h"
#include "Debug.h"
// ---------------------------------------------------------------------------------------------------------------
using namespace UniSetTypes;
using namespace std;
using namespace omni;
// ---------------------------------------------------------------------------------------------------------------
ObjectRepositoryFactory::ObjectRepositoryFactory( const std::shared_ptr<UniSetTypes::Configuration>& _conf ):
ObjectRepository(_conf)
{
}
ObjectRepositoryFactory::~ObjectRepositoryFactory()
{
}
// -------------------------------------------------------------------------------------------------------
/*!
* \param name - имя создаваемой секции
* \param in_section - полное имя секции внутри которой создается новая
* \param section - полное имя секции начиная с Root.
* \exception ORepFailed - генерируется если произошла при получении доступа к секции
*/
bool ObjectRepositoryFactory::createSection(const string& name, const string& in_section)throw(ORepFailed, InvalidObjectName)
{
char bad = ORepHelpers::checkBadSymbols(name);
if (bad != 0)
{
ostringstream err;
err << "ObjectRepository(registration): (InvalidObjectName) " << name;
err << " содержит недопустимый символ " << bad;
throw ( InvalidObjectName(err.str().c_str()) );
}
ulogrep << "CreateSection: name = " << name << " in section = " << in_section << endl;
if( in_section.empty() )
{
ulogrep << "CreateSection: in_section..empty" << endl;
return createRootSection(name);
}
int argc(uconf->getArgc());
const char* const* argv(uconf->getArgv());
CosNaming::NamingContext_var ctx = ORepHelpers::getContext(in_section, argc, argv, uconf->getNSName() );
return createContext( name, ctx.in() );
}
// -------------------------------------------------------------------------------------------------------
/*!
* \param fullName - полное имя создаваемой секции
* \exception ORepFailed - генерируется если произошла при получении доступа к секции
*/
bool ObjectRepositoryFactory::createSectionF(const string& fullName)throw(ORepFailed, InvalidObjectName)
{
string name(ObjectIndex::getBaseName(fullName));
string sec(ORepHelpers::getSectionName(fullName));
ulogrep << name << endl;
ulogrep << sec << endl;
if ( sec.empty() )
{
ulogrep << "SectionName is empty!!!" << endl;
ulogrep << "Добавляем в " << uconf->getRootSection() << endl;
return createSection(name, uconf->getRootSection());
}
else
return createSection(name, sec);
}
// ---------------------------------------------------------------------------------------------------------------
bool ObjectRepositoryFactory::createRootSection( const string& name )
{
CORBA::ORB_var orb = uconf->getORB();
CosNaming::NamingContext_var ctx = ORepHelpers::getRootNamingContext(orb, uconf->getNSName());
return createContext(name, ctx);
}
// -----------------------------------------------------------------------------------------------------------
bool ObjectRepositoryFactory::createContext( const string& cname, CosNaming::NamingContext_ptr ctx )
{
CosNaming::Name_var nc = omniURI::stringToName(cname.c_str());
try
{
ulogrep << "ORepFactory(createContext): создаю новый контекст " << cname << endl;
ctx->bind_new_context(nc);
ulogrep << "ORepFactory(createContext): создал. " << endl;
return true;
}
catch(const CosNaming::NamingContext::AlreadyBound& ab)
{
// ctx->resolve(nc);
ulogrep << "ORepFactory(createContext): context " << cname << " уже есть" << endl;
return true;
}
catch( const CosNaming::NamingContext::NotFound )
{
ulogrep << "ORepFactory(createContext): NotFound " << cname << endl;
throw NameNotFound();
}
catch( const CosNaming::NamingContext::InvalidName& nf )
{
uwarn << "ORepFactory(createContext): (InvalidName) " << cname;
}
catch( const CosNaming::NamingContext::CannotProceed& cp )
{
uwarn << "ORepFactory(createContext): catch CannotProced "
<< cname << " bad part="
<< omniURI::nameToString(cp.rest_of_name);
throw NameNotFound();
}
catch( const CORBA::SystemException& ex )
{
ucrit << "ORepFactory(createContext): CORBA::SystemException: "
<< ex.NP_minorString() << endl;
}
catch( const CORBA::Exception& )
{
ucrit << "поймали CORBA::Exception." << endl;
}
catch( const omniORB::fatalException& fe )
{
ucrit << "поймали omniORB::fatalException:" << endl;
ucrit << " file: " << fe.file() << endl;
ucrit << " line: " << fe.line() << endl;
ucrit << " mesg: " << fe.errmsg() << endl;
}
return false;
}
// -----------------------------------------------------------------------------------------------------------
/*!
\note Функция не вывести список, если не сможет получить доступ к секции
*/
void ObjectRepositoryFactory::printSection( const string& fullName )
{
ListObjectName ls;
try
{
list(fullName.c_str(), &ls);
if( ls.empty() )
cout << fullName << " пуст!!!" << endl;
}
catch( ORepFailed )
{
cout << "printSection: cath exceptions ORepFailed..." << endl;
return ;
}
cout << fullName << "(" << ls.size() << "):" << endl;
for( auto v : ls )
cout << v << endl;
}
// -----------------------------------------------------------------------------------------------------------
/*!
* \param fullName - имя удаляемой секции
* \param recursive - удлаять рекурсивно все секции или возвращать не удалять и ошибку ( временно )
* \warning Функция вынимает только первые 1000 объектов, остальные игнорируются...
*/
bool ObjectRepositoryFactory::removeSection(const string& fullName, bool recursive)
{
// string name = getName(fullName.c_str(),'/');
// string sec = getSectionName(fullName.c_str(),'/');
// CosNaming::NamingContext_var ctx = getContext(sec, argc, argv);
unsigned int how_many = 1000;
CosNaming::NamingContext_var ctx;
try
{
int argc(uconf->getArgc());
const char* const* argv(uconf->getArgv());
ctx = ORepHelpers::getContext(fullName, argc, argv, nsName);
}
catch( ORepFailed )
{
return false;
}
CosNaming::BindingList_var bl;
CosNaming::BindingIterator_var bi;
ctx->list(how_many, bl, bi);
// хитрая проверка на null приобращении к bl
// coverity говорит потенциально это возможно
// т.к. там возвращается указатель, который по умолчанию null
if( !bl.operator->() )
return false;
if( how_many > bl->length() )
how_many = bl->length();
bool rem = true; // удалять или нет
for(unsigned int i = 0; i < how_many; i++)
{
if( bl[i].binding_type == CosNaming::nobject)
{
// cout <<"удаляем "<< omniURI::nameToString(bl[i].binding_name) << endl;
ctx->unbind(bl[i].binding_name);
}
else if( bl[i].binding_type == CosNaming::ncontext)
{
if( recursive )
{
ulogrep << "ORepFactory: удаляем рекурсивно..." << endl;
string rctx = fullName + "/" + omniURI::nameToString(bl[i].binding_name);
ulogrep << rctx << endl;
if ( !removeSection(rctx))
{
ulogrep << "рекурсивно удалить не удалось" << endl;
rem = false;
}
}
else
{
ulogrep << "ORepFactory: " << omniURI::nameToString(bl[i].binding_name) << " - контекст!!! ";
ulogrep << "ORepFactory: пока не удаляем" << endl;
rem = false;
}
}
}
// Удаляем контекст, если он уже пустой
if( rem )
{
// Получаем имя контекста содержащего удаляемый
string in_sec(ORepHelpers::getSectionName(fullName));
//Получаем имя удаляемого контекста
string name(ObjectIndex::getBaseName(fullName));
try
{
int argc(uconf->getArgc());
const char* const* argv(uconf->getArgv());
CosNaming::Name_var ctxName = omniURI::stringToName(name.c_str());
CosNaming::NamingContext_var in_ctx = ORepHelpers::getContext(in_sec, argc, argv, nsName);
ctx->destroy();
in_ctx->unbind(ctxName);
}
catch(const CosNaming::NamingContext::NotEmpty& ne)
{
ulogrep << "ORepFactory: контекст" << fullName << " не пустой " << endl;
rem = false;
}
catch( ORepFailed )
{
ulogrep << "ORepFactory: не удаось получить ссылку на контекст " << in_sec << endl;
rem = false;
}
}
if( !CORBA::is_nil(bi) )
bi->destroy(); // ??
return rem;
}
// -----------------------------------------------------------------------------------------------------------
/*!
* \param newFName - полное имя новой секции
* \param oldFName - полное имя удаляемрй секции
*/
bool ObjectRepositoryFactory::renameSection( const string& newFName, const string& oldFName )
{
string newName(ObjectIndex::getBaseName(newFName));
string oldName(ObjectIndex::getBaseName(oldFName));
CosNaming::Name_var ctxNewName = omniURI::stringToName(newName.c_str());
CosNaming::Name_var ctxOldName = omniURI::stringToName(oldName.c_str());
string in_sec(ORepHelpers::getSectionName(newFName));
try
{
int argc(uconf->getArgc());
const char* const* argv(uconf->getArgv());
CosNaming::NamingContext_var in_ctx = ORepHelpers::getContext(in_sec, argc, argv, nsName);
CosNaming::NamingContext_var ctx = ORepHelpers::getContext(oldFName, argc, argv, nsName);
// заменит контекст newFName если он существовал
in_ctx->rebind_context(ctxNewName, ctx);
in_ctx->unbind(ctxOldName);
}
catch( ORepFailed )
{
return false;
}
return true;
}
// -----------------------------------------------------------------------------------------------------------
......@@ -302,7 +302,6 @@ include/ObjectIndex_Array.h
include/ObjectIndex_idXML.h
include/ObjectIndex_XML.h
include/ObjectRepository.h
include/ObjectRepositoryFactory.h
include/OmniThreadCreator.h
include/ORepHelpers.h
include/PassiveObject.h
......@@ -396,7 +395,6 @@ src/ObjectRepository/ObjectIndex_Array.cc
src/ObjectRepository/ObjectIndex_idXML.cc
src/ObjectRepository/ObjectIndex_XML.cc
src/ObjectRepository/ObjectRepository.cc
src/ObjectRepository/ObjectRepositoryFactory.cc
src/ObjectRepository/ORepHelpers.cc
src/ObjectRepository/PassiveObject.cc
src/ObjectRepository/ProxyManager.cc
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment