Commit d5d1d2b8 authored by Pavel Vainerman's avatar Pavel Vainerman

(IORFile): небольшой рефакторинг интерфейса. Сделал функции статическими,

т.к. по сути это класс "вспомогательных функций". (codegen): небольшая правка параметра для натстройки лога, перегенерировал UObject_SK
parent 856d7807
...@@ -634,7 +634,7 @@ end_private(false) ...@@ -634,7 +634,7 @@ end_private(false)
mylog->setLogName(myname); mylog->setLogName(myname);
{ {
ostringstream s; ostringstream s;
s << myname << "-log"; s << argprefix << "log";
conf->initLogStream(mylog,s.str()); conf->initLogStream(mylog,s.str());
} }
...@@ -965,7 +965,7 @@ askPause(uniset_conf()->getPIntProp(cnode,"askPause",2000)) ...@@ -965,7 +965,7 @@ askPause(uniset_conf()->getPIntProp(cnode,"askPause",2000))
mylog->setLogName(myname); mylog->setLogName(myname);
{ {
ostringstream s; ostringstream s;
s << myname << "-log"; s << argprefix << "log";
conf->initLogStream(mylog, s.str()); conf->initLogStream(mylog, s.str());
} }
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
Name: libuniset2 Name: libuniset2
Version: 2.0 Version: 2.0
Release: alt17 Release: alt18
Summary: UniSet - library for building distributed industrial control systems Summary: UniSet - library for building distributed industrial control systems
...@@ -404,8 +404,16 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname ...@@ -404,8 +404,16 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname
#%_pkgconfigdir/libUniSet2SMDBServer.pc #%_pkgconfigdir/libUniSet2SMDBServer.pc
#%_pkgconfigdir/libUniSet2*.pc #%_pkgconfigdir/libUniSet2*.pc
%exclude %_pkgconfigdir/libUniSet2.pc %exclude %_pkgconfigdir/libUniSet2.pc
# history of current unpublished changes
# ..
%changelog %changelog
* Sat Feb 28 2015 Pavel Vainerman <pv@altlinux.ru> 2.0-alt18
- codegen: set default argprefix=myname (object name)
- codegen: fixed minor bug in mylog..
- refactoring IORFile interface
* Sat Feb 21 2015 Pavel Vainerman <pv@altlinux.ru> 2.0-alt17 * Sat Feb 21 2015 Pavel Vainerman <pv@altlinux.ru> 2.0-alt17
- use omni_options[] argument for ORB_init(). - use omni_options[] argument for ORB_init().
- minor fixes - minor fixes
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
ВСЕ ВАШИ ИЗМЕНЕНИЯ БУДУТ ПОТЕРЯНЫ. ВСЕ ВАШИ ИЗМЕНЕНИЯ БУДУТ ПОТЕРЯНЫ.
*/ */
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// generate timestamp: 2015-02-02+03:00 // generate timestamp: 2015-02-28+03:00
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
#ifndef UObject_SK_H_ #ifndef UObject_SK_H_
#define UObject_SK_H_ #define UObject_SK_H_
...@@ -42,18 +42,18 @@ class UObject_SK: ...@@ -42,18 +42,18 @@ class UObject_SK:
void init_dlog( std::shared_ptr<DebugStream> d ); void init_dlog( std::shared_ptr<DebugStream> d );
// "синтаксический сахар"..для логов // "синтаксический сахар"..для логов
#define myinfo if( mylog->debugging(Debug::INFO) ) mylog->any() #define myinfo if( mylog->debugging(Debug::INFO) ) mylog->info()
#define mywarn if( mylog->debugging(Debug::WARN) ) mylog->any() #define mywarn if( mylog->debugging(Debug::WARN) ) mylog->warn()
#define mycrit if( mylog->debugging(Debug::CRIT) ) mylog->any() #define mycrit if( mylog->debugging(Debug::CRIT) ) mylog->crit()
#define mylog1 if( mylog->debugging(Debug::LEVEL1) ) mylog->any() #define mylog1 if( mylog->debugging(Debug::LEVEL1) ) mylog->level1()
#define mylog2 if( mylog->debugging(Debug::LEVEL2) ) mylog->any() #define mylog2 if( mylog->debugging(Debug::LEVEL2) ) mylog->level2()
#define mylog3 if( mylog->debugging(Debug::LEVEL3) ) mylog->any() #define mylog3 if( mylog->debugging(Debug::LEVEL3) ) mylog->level3()
#define mylog4 if( mylog->debugging(Debug::LEVEL4) ) mylog->any() #define mylog4 if( mylog->debugging(Debug::LEVEL4) ) mylog->level4()
#define mylog5 if( mylog->debugging(Debug::LEVEL5) ) mylog->any() #define mylog5 if( mylog->debugging(Debug::LEVEL5) ) mylog->level5()
#define mylog6 if( mylog->debugging(Debug::LEVEL6) ) mylog->any() #define mylog6 if( mylog->debugging(Debug::LEVEL6) ) mylog->level6()
#define mylog7 if( mylog->debugging(Debug::LEVEL7) ) mylog->any() #define mylog7 if( mylog->debugging(Debug::LEVEL7) ) mylog->level7()
#define mylog8 if( mylog->debugging(Debug::LEVEL8) ) mylog->any() #define mylog8 if( mylog->debugging(Debug::LEVEL8) ) mylog->level8()
#define mylog9 if( mylog->debugging(Debug::LEVEL9) ) mylog->any() #define mylog9 if( mylog->debugging(Debug::LEVEL9) ) mylog->level9()
#define mylogany mylog->any() #define mylogany mylog->any()
...@@ -107,6 +107,7 @@ class UObject_SK: ...@@ -107,6 +107,7 @@ class UObject_SK:
int sleep_msec; /*!< пауза между итерациями */ int sleep_msec; /*!< пауза между итерациями */
bool active; bool active;
const std::string argprefix;
UniSetTypes::ObjectId smTestID; /*!< идентификатор датчика для тестирования готовности SM */ UniSetTypes::ObjectId smTestID; /*!< идентификатор датчика для тестирования готовности SM */
// управление датчиком "сердцебиения" // управление датчиком "сердцебиения"
......
...@@ -37,12 +37,13 @@ class IORFile ...@@ -37,12 +37,13 @@ class IORFile
public: public:
IORFile(); IORFile();
std::string getIOR( const ObjectId id ) const; static std::string getIOR( const ObjectId id );
void setIOR( const ObjectId id, const std::string& sior ) const; static void setIOR( const ObjectId id, const std::string& sior );
void unlinkIOR( const ObjectId id ) const; static void unlinkIOR( const ObjectId id );
static std::string getFileName( const ObjectId id );
protected: protected:
std::string genFName( const ObjectId id ) const;
private: private:
}; };
......
...@@ -37,9 +37,9 @@ IORFile::IORFile() ...@@ -37,9 +37,9 @@ IORFile::IORFile()
} }
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
string IORFile::getIOR( const ObjectId id ) const string IORFile::getIOR( const ObjectId id )
{ {
string fname( genFName(id) ); string fname( getFileName(id) );
ifstream ior_file(fname.c_str()); ifstream ior_file(fname.c_str());
string sior; string sior;
ior_file >> sior; ior_file >> sior;
...@@ -47,9 +47,9 @@ string IORFile::getIOR( const ObjectId id ) const ...@@ -47,9 +47,9 @@ string IORFile::getIOR( const ObjectId id ) const
return std::move(sior); return std::move(sior);
} }
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
void IORFile::setIOR( const ObjectId id, const string& sior ) const void IORFile::setIOR( const ObjectId id, const string& sior )
{ {
string fname( genFName(id) ); string fname( getFileName(id) );
ofstream ior_file(fname.c_str(), ios::out | ios::trunc); ofstream ior_file(fname.c_str(), ios::out | ios::trunc);
if( !ior_file ) if( !ior_file )
...@@ -62,13 +62,13 @@ void IORFile::setIOR( const ObjectId id, const string& sior ) const ...@@ -62,13 +62,13 @@ void IORFile::setIOR( const ObjectId id, const string& sior ) const
ior_file.close(); ior_file.close();
} }
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
void IORFile::unlinkIOR( const ObjectId id ) const void IORFile::unlinkIOR( const ObjectId id )
{ {
string fname( genFName(id) ); string fname( getFileName(id) );
unlink(fname.c_str()); unlink(fname.c_str());
} }
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
string IORFile::genFName( const ObjectId id ) const string IORFile::getFileName( const ObjectId id )
{ {
ostringstream fname; ostringstream fname;
fname << uniset_conf()->getLockDir() << id; fname << uniset_conf()->getLockDir() << id;
......
...@@ -17,12 +17,8 @@ TEST_CASE("IORFile", "[iorfile][basic]" ) ...@@ -17,12 +17,8 @@ TEST_CASE("IORFile", "[iorfile][basic]" )
ior.setIOR(testID,iorstr); ior.setIOR(testID,iorstr);
REQUIRE( ior.getIOR(testID) == iorstr ); REQUIRE( ior.getIOR(testID) == iorstr );
// здесь выносим "наружу" немного "внутренней кухни" IORFile, CHECK( file_exist(ior.getFileName(testID)) );
// т.к. снаружи не известно как формируется "название файла"
ostringstream s;
s << uniset_conf()->getLockDir() << testID;
CHECK( file_exist(s.str()) );
ior.unlinkIOR(testID); ior.unlinkIOR(testID);
CHECK_FALSE( file_exist(s.str()) ); CHECK_FALSE( file_exist(ior.getFileName(testID)) );
} }
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