Commit 1b8e0075 authored by Pavel Vainerman's avatar Pavel Vainerman

Рефаторинг: очередная расстановка const

parent 97c81e52
......@@ -26,7 +26,7 @@ namespace uniset
const Element::ElementID Element::DefaultElementID = "?id?";
// -------------------------------------------------------------------------
void Element::addChildOut( std::shared_ptr<Element> el, size_t num )
void Element::addChildOut( std::shared_ptr<Element>& el, size_t num )
{
if( el.get() == this )
{
......@@ -38,7 +38,7 @@ namespace uniset
for( const auto& it : outs )
{
if( it.el == el )
if( it.el.get() == el.get() )
{
ostringstream msg;
msg << "(" << myid << "):" << el->getId() << " уже есть в списке дочерних(такое соединение уже есть)...";
......@@ -59,11 +59,11 @@ namespace uniset
outs.emplace_front(el, num);
}
// -------------------------------------------------------------------------
void Element::delChildOut( std::shared_ptr<Element> el )
void Element::delChildOut( std::shared_ptr<Element>& el )
{
for( auto it = outs.begin(); it != outs.end(); ++it )
{
if( it->el == el )
if( it->el.get() == el.get() )
{
outs.erase(it);
return;
......@@ -135,12 +135,12 @@ namespace uniset
return ins.size();
}
// -------------------------------------------------------------------------
ostream& operator<<( ostream& os, Element& el )
ostream& operator<<( ostream& os, const Element& el )
{
return os << "[" << el.getType() << "]" << el.getId();
}
ostream& operator<<( ostream& os, std::shared_ptr<Element> el )
ostream& operator<<( ostream& os, const std::shared_ptr<Element>& el )
{
if( el )
return os << (*(el.get()));
......
......@@ -72,16 +72,16 @@ namespace uniset
virtual std::shared_ptr<Element> find( const ElementID& id );
virtual void addChildOut( std::shared_ptr<Element> el, size_t in_num );
virtual void delChildOut( std::shared_ptr<Element> el );
virtual void addChildOut( std::shared_ptr<Element>& el, size_t in_num );
virtual void delChildOut( std::shared_ptr<Element>& el );
size_t outCount() const;
virtual void addInput( size_t num, long value = 0 );
virtual void delInput( size_t num );
size_t inCount() const;
friend std::ostream& operator<<(std::ostream& os, Element& el );
friend std::ostream& operator<<(std::ostream& os, std::shared_ptr<Element> el );
friend std::ostream& operator<<(std::ostream& os, const Element& el );
friend std::ostream& operator<<(std::ostream& os, const std::shared_ptr<Element>& el );
protected:
Element(): myid(DefaultElementID) {}; // нельзя создать элемент без id
......
......@@ -138,7 +138,7 @@ namespace uniset
return el;
}
// -------------------------------------------------------------------------
void Schema::remove( std::shared_ptr<Element> el )
void Schema::remove( std::shared_ptr<Element>& el )
{
for( auto && it = emap.begin(); it != emap.end(); ++it )
{
......
......@@ -33,7 +33,7 @@ namespace uniset
std::shared_ptr<Element> manage( std::shared_ptr<Element> el );
void remove( std::shared_ptr<Element> el );
void remove( std::shared_ptr<Element>& el );
void link( Element::ElementID rootID, Element::ElementID childID, int numIn );
void unlink( Element::ElementID rootID, Element::ElementID childID );
......
......@@ -118,26 +118,22 @@ namespace uniset
*/
timeout_t checkTimers( UniSetObject* obj );
/*! получить текущее время ожидания */
//inline timeout_t getSleepTimeMS(){ return sleepTime; }
/*! получить время на которое установлен таймер timerid
* \param timerid - идентификатор таймера
* \return 0 - если таймер не найден, время (мсек) если таймер есть.
*/
timeout_t getTimeInterval( uniset::TimerId timerid );
timeout_t getTimeInterval( uniset::TimerId timerid ) const;
/*! получить оставшееся время для таймера timerid
* \param timerid - идентификатор таймера
* \return 0 - если таймер не найден, время (мсек) если таймер есть.
*/
timeout_t getTimeLeft( uniset::TimerId timerid );
timeout_t getTimeLeft( uniset::TimerId timerid ) const;
protected:
/*! пользовательская функция для вывода названия таймера */
virtual std::string getTimerName( int id );
virtual std::string getTimerName( int id ) const;
/*! Информация о таймере */
struct TimerInfo
......@@ -159,7 +155,7 @@ namespace uniset
}
uniset::TimerId id = { 0 }; /*!< идентификатор таймера */
timeout_t curTimeMS = { 0 }; /*!< остаток времени */
timeout_t curTimeMS = { 0 }; /*!< остаток времени */
uniset::Message::Priority priority = { uniset::Message::High }; /*!< приоритет посылаемого сообщения */
/*!
......@@ -195,13 +191,13 @@ namespace uniset
timeout_t sleepTime; /*!< текущее время ожидания */
TimersList getTimersList();
TimersList getTimersList() const;
private:
TimersList tlst;
/*! замок для блокирования совместного доступа к cписку таймеров */
uniset::uniset_rwmutex lstMutex;
mutable uniset::uniset_rwmutex lstMutex;
PassiveTimer tmLast;
};
// -------------------------------------------------------------------------
......
......@@ -35,8 +35,7 @@ namespace uniset
namespace ORepHelpers
{
//! Получение ссылки на корень репозитория
CosNaming::NamingContext_ptr getRootNamingContext( const CORBA::ORB_ptr orb,
const std::string& nsName, int timeOutSec = 2);
CosNaming::NamingContext_ptr getRootNamingContext( const CORBA::ORB_ptr orb, const std::string& nsName );
//! Получение контекста по заданному имени
CosNaming::NamingContext_ptr getContext(const std::string& cname, int argc,
......
......@@ -15,7 +15,7 @@
*/
// --------------------------------------------------------------------------
/*! \file
* \author Vitaly Lipatov
* \author Vitaly Lipatov, Pavel Vainerman
*/
// --------------------------------------------------------------------------
#ifndef ObjcetIndex_H_
......@@ -27,6 +27,7 @@
// --------------------------------------------------------------------------
namespace uniset
{
/*! Базовый интерфейс для работы с преобразованиями ObjectID <--> ObjectName */
class ObjectIndex
{
public:
......
......@@ -31,9 +31,13 @@
namespace uniset
{
/*!
\todo Проверить функции этого класса на повторную входимость
\bug При обращении к objectsMap[0].textName срабатывает исключение(видимо какое-то из std).
Требуется дополнительное изучение.
*
* \todo Проверить функции этого класса на повторную входимость
* \bug При обращении к objectsMap[0].textName срабатывает исключение(видимо какое-то из std).
* Требуется дополнительное изучение.
*
* \deprecated Этот класс нужен для совместимости с очень древними проектами.
* Где список объектов объявлялся статическим массивом
*/
class ObjectIndex_Array:
public ObjectIndex
......
......@@ -31,7 +31,10 @@
namespace uniset
{
/*! \todo Проверить функции этого класса на повторную входимость */
/*! реализация интерфейса ObjectIndex на основе xml-файла, с автоматическим назначением id объектам
*
* \todo Проверить функции этого класса на повторную входимость
*/
class ObjectIndex_XML:
public ObjectIndex
{
......
......@@ -24,7 +24,7 @@
// --------------------------------------------------------------------------
namespace uniset
{
/*! реализация интерфейса ObjectIndex на основе xml-файла, в котором прописаны id объектов */
class ObjectIndex_idXML:
public uniset::ObjectIndex
{
......
......@@ -37,9 +37,9 @@ namespace uniset
/*! \class ObjectRepository
* \par
* ... а здесь идет кратенькое описание... (коротенько минут на 40!...)
* Работа с CORBA-репозиторием (NameService).
*
* \note Репозиторий работает только, с локальным репозиторием
* \note Репозиторий работает только, с локальным репозиторием
* \todo получение списка начиная с элемента номер N.
*/
class ObjectRepository
......@@ -54,16 +54,19 @@ namespace uniset
@{ */
//! Функция регистрации объекта по имени с указанием секции
void registration(const std::string& name, const uniset::ObjectPtr oRef, const std::string& section, bool force = false) const
throw(uniset::ORepFailed, uniset::ObjectNameAlready, uniset::InvalidObjectName, uniset::NameNotFound);
throw(uniset::ORepFailed, uniset::ObjectNameAlready, uniset::InvalidObjectName, uniset::NameNotFound);
//! Функция регистрации объекта по полному имени.
void registration(const std::string& fullName, const uniset::ObjectPtr oRef, bool force = false) const
throw(uniset::ORepFailed, uniset::ObjectNameAlready, uniset::InvalidObjectName, uniset::NameNotFound);
throw(uniset::ORepFailed, uniset::ObjectNameAlready, uniset::InvalidObjectName, uniset::NameNotFound);
//! Удаление записи об объекте name в секции section
void unregistration(const std::string& name, const std::string& section) const throw(uniset::ORepFailed, uniset::NameNotFound);
void unregistration(const std::string& name, const std::string& section) const
throw(uniset::ORepFailed, uniset::NameNotFound);
//! Удаление записи об объекте по полному имени
void unregistration(const std::string& fullName) const throw(uniset::ORepFailed, uniset::NameNotFound);
void unregistration(const std::string& fullName) const
throw(uniset::ORepFailed, uniset::NameNotFound);
// @}
// end of ORepGroup
......@@ -95,19 +98,21 @@ namespace uniset
// -------------------------------------------------------------------
//! Создание секции
bool createSection( const std::string& name, const std::string& in_section )throw(uniset::ORepFailed, uniset::InvalidObjectName);
bool createSection( const std::string& name, const std::string& in_section ) const
throw(uniset::ORepFailed, uniset::InvalidObjectName);
/*! Создание секции по полному имени */
bool createSectionF(const std::string& fullName)throw(uniset::ORepFailed, uniset::InvalidObjectName);
bool createSectionF(const std::string& fullName) const
throw(uniset::ORepFailed, uniset::InvalidObjectName);
//! Функция создания секции в корневом 'каталоге'
bool createRootSection(const std::string& name);
bool createRootSection( const std::string& name ) const;
//! Функция удаления секции
bool removeSection(const std::string& fullName, bool recursive = false);
bool removeSection(const std::string& fullName, bool recursive = false) const;
//! Функция переименования секции
bool renameSection(const std::string& newName, const std::string& fullName);
bool renameSection(const std::string& newName, const std::string& fullName) const;
/*! Функция выводящая на экран список всех объектов расположенных в данной секции */
void printSection(const std::string& fullName) const;
......@@ -124,7 +129,7 @@ namespace uniset
bool list(const std::string& section, uniset::ListObjectName* ls, size_t how_many, ObjectType type) const;
/*! Создание нового контекста(секции) */
bool createContext( const std::string& cname, CosNaming::NamingContext_ptr ctx);
bool createContext( const std::string& cname, CosNaming::NamingContext_ptr ctx) const;
private:
bool init() const;
......
......@@ -99,7 +99,7 @@ namespace uniset
OmniThreadCreator( const std::shared_ptr<ThreadMaster>& m, Action a, bool undetached = false );
~OmniThreadCreator() {}
inline bool isRunning()
inline bool isRunning() const
{
return state() == omni_thread::STATE_RUNNING;
}
......
......@@ -114,7 +114,7 @@ namespace uniset
protected:
void check();
InputMap inputs; // список входов
bool out;
bool out = { false };
Caller* cal;
Action act;
};
......
......@@ -113,7 +113,7 @@ namespace uniset
void check();
InputMap inputs; // список входов
bool out;
bool out = { false };
Caller* cal;
Action act;
};
......
......@@ -137,7 +137,7 @@ namespace uniset
// ---------------------------------------------------------------------------------------------------------------
/*! \param orb - ссылка на ORB */
CosNaming::NamingContext_ptr getRootNamingContext(const CORBA::ORB_ptr orb, const string& nsName, int timeoutSec)
CosNaming::NamingContext_ptr getRootNamingContext( const CORBA::ORB_ptr orb, const string& nsName )
{
CosNaming::NamingContext_var rootContext;
......
......@@ -449,7 +449,8 @@ bool ObjectRepository::isExist( const ObjectPtr& oref ) const
* \param section - полное имя секции начиная с Root.
* \exception ORepFailed - генерируется если произошла при получении доступа к секции
*/
bool ObjectRepository::createSection(const string& name, const string& in_section)throw(ORepFailed, InvalidObjectName)
bool ObjectRepository::createSection(const string& name, const string& in_section) const
throw(ORepFailed, InvalidObjectName)
{
char bad = ORepHelpers::checkBadSymbols(name);
......@@ -471,7 +472,7 @@ bool ObjectRepository::createSection(const string& name, const string& in_sectio
int argc(uconf->getArgc());
const char* const* argv(uconf->getArgv());
CosNaming::NamingContext_var ctx = ORepHelpers::getContext(in_section, argc, argv, uconf->getNSName() );
CosNaming::NamingContext_var ctx = ORepHelpers::getContext(in_section, argc, argv, nsName );
return createContext( name, ctx.in() );
}
// -------------------------------------------------------------------------------------------------------
......@@ -479,7 +480,7 @@ bool ObjectRepository::createSection(const string& name, const string& in_sectio
* \param fullName - полное имя создаваемой секции
* \exception ORepFailed - генерируется если произошла при получении доступа к секции
*/
bool ObjectRepository::createSectionF( const string& fullName )throw(ORepFailed, InvalidObjectName)
bool ObjectRepository::createSectionF( const string& fullName ) const throw(ORepFailed, InvalidObjectName)
{
string name(ObjectIndex::getBaseName(fullName));
string sec(ORepHelpers::getSectionName(fullName));
......@@ -498,14 +499,14 @@ bool ObjectRepository::createSectionF( const string& fullName )throw(ORepFailed,
}
// ---------------------------------------------------------------------------------------------------------------
bool ObjectRepository::createRootSection( const string& name )
bool ObjectRepository::createRootSection( const string& name ) const
{
CORBA::ORB_var orb = uconf->getORB();
CosNaming::NamingContext_var ctx = ORepHelpers::getRootNamingContext(orb, uconf->getNSName());
CosNaming::NamingContext_var ctx = ORepHelpers::getRootNamingContext(orb, nsName);
return createContext(name, ctx);
}
// -----------------------------------------------------------------------------------------------------------
bool ObjectRepository::createContext( const string& cname, CosNaming::NamingContext_ptr ctx )
bool ObjectRepository::createContext( const string& cname, CosNaming::NamingContext_ptr ctx ) const
{
CosNaming::Name_var nc = omniURI::stringToName(cname.c_str());
......@@ -591,12 +592,12 @@ void ObjectRepository::printSection( const string& fullName ) const
* \param recursive - удлаять рекурсивно все секции или возвращать не удалять и ошибку ( временно )
* \warning Функция вынимает только первые 1000 объектов, остальные игнорируются...
*/
bool ObjectRepository::removeSection(const string& fullName, bool recursive)
bool ObjectRepository::removeSection( const string& fullName, bool recursive ) const
{
// 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;
size_t how_many = 1000;
CosNaming::NamingContext_var ctx;
try
......@@ -626,7 +627,7 @@ bool ObjectRepository::removeSection(const string& fullName, bool recursive)
bool rem = true; // удалять или нет
for(unsigned int i = 0; i < how_many; i++)
for( size_t i = 0; i < how_many; i++)
{
if( bl[i].binding_type == CosNaming::nobject)
......@@ -700,7 +701,7 @@ bool ObjectRepository::removeSection(const string& fullName, bool recursive)
* \param newFName - полное имя новой секции
* \param oldFName - полное имя удаляемрй секции
*/
bool ObjectRepository::renameSection( const string& newFName, const string& oldFName )
bool ObjectRepository::renameSection( const string& newFName, const string& oldFName ) const
{
string newName(ObjectIndex::getBaseName(newFName));
string oldName(ObjectIndex::getBaseName(oldFName));
......
......@@ -123,7 +123,7 @@ timeout_t LT_Object::checkTimers( UniSetObject* obj )
return sleepTime;
}
// ------------------------------------------------------------------------------------------
timeout_t LT_Object::getTimeInterval( TimerId timerid )
timeout_t LT_Object::getTimeInterval( TimerId timerid ) const
{
// lock
uniset_rwmutex_rlock lock(lstMutex);
......@@ -137,7 +137,7 @@ timeout_t LT_Object::getTimeInterval( TimerId timerid )
return 0;
}
// ------------------------------------------------------------------------------------------
timeout_t LT_Object::getTimeLeft( TimerId timerid )
timeout_t LT_Object::getTimeLeft( TimerId timerid ) const
{
// lock
uniset_rwmutex_rlock lock(lstMutex);
......@@ -151,14 +151,14 @@ timeout_t LT_Object::getTimeLeft( TimerId timerid )
return 0;
}
// ------------------------------------------------------------------------------------------
LT_Object::TimersList LT_Object::getTimersList()
LT_Object::TimersList LT_Object::getTimersList() const
{
uniset_rwmutex_rlock l(lstMutex);
TimersList lst(tlst);
return lst;
}
// ------------------------------------------------------------------------------------------
string LT_Object::getTimerName(int id)
string LT_Object::getTimerName( int id ) const
{
return "";
}
......
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