Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
uniset2
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UniSet project repositories
uniset2
Commits
dab976bb
Commit
dab976bb
authored
Nov 24, 2014
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Перевёл Configuration::oind (ObjectIndex) на shared_ptr.
Заодно и IORFile.
parent
255cd3db
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
30 additions
and
24 deletions
+30
-24
mbslave-tests.cc
extensions/ModbusSlave/tests/mbslave-tests.cc
+1
-1
ui.cc
extensions/tests/ui.cc
+1
-1
Configuration.h
include/Configuration.h
+3
-3
UInterface.h
include/UInterface.h
+4
-3
UInterface.cc
src/Interfaces/UInterface.cc
+5
-5
Configuration.cc
src/Various/Configuration.cc
+15
-10
ui.cc
tests/ui.cc
+1
-1
No files found.
extensions/ModbusSlave/tests/mbslave-tests.cc
View file @
dab976bb
...
...
@@ -24,7 +24,7 @@ void InitTest()
{
ui
=
new
UInterface
();
// UI понадобиться для проверки записанных в SM значений.
CHECK
(
ui
->
getObjectIndex
()
!=
0
);
CHECK
(
ui
->
getObjectIndex
()
!=
nullptr
);
CHECK
(
ui
->
getConf
()
==
UniSetTypes
::
conf
);
CHECK
(
ui
->
waitReady
(
slaveID
,
5000
)
);
}
...
...
extensions/tests/ui.cc
View file @
dab976bb
...
...
@@ -25,7 +25,7 @@ TEST_CASE("UInterface","[UInterface]")
UInterface
ui
;
CHECK
(
ui
.
getObjectIndex
()
!=
0
);
CHECK
(
ui
.
getObjectIndex
()
!=
nullptr
);
CHECK
(
ui
.
getConf
()
==
UniSetTypes
::
conf
);
REQUIRE
(
ui
.
getConfIOType
(
sid
)
==
UniversalIO
::
DI
);
...
...
include/Configuration.h
View file @
dab976bb
...
...
@@ -53,7 +53,7 @@ namespace UniSetTypes
Configuration
(
int
argc
,
const
char
*
const
*
argv
,
const
std
::
string
&
xmlfile
=
""
);
/*! конфигурирование xml-файлом */
Configuration
(
int
argc
,
const
char
*
const
*
argv
,
ObjectIndex
*
oind
,
const
std
::
string
&
xmlfile
=
""
);
Configuration
(
int
argc
,
const
char
*
const
*
argv
,
std
::
shared_ptr
<
ObjectIndex
>
oind
,
const
std
::
string
&
xmlfile
=
""
);
/*! устаревший вариант, для поддержки старых проектов */
Configuration
(
int
argc
,
const
char
*
const
*
argv
,
...
...
@@ -152,10 +152,10 @@ namespace UniSetTypes
}
/*! интерфейс к карте объектов */
ObjectIndex
*
oind
;
std
::
shared_ptr
<
ObjectIndex
>
oind
;
/*! интерфейс к работе с локальнымми ior-файлами */
IORFile
iorfile
;
std
::
shared_ptr
<
IORFile
>
iorfile
;
/*! указатель на конфигурационный xml */
inline
const
std
::
shared_ptr
<
UniXML
>
getConfXML
()
const
{
return
unixml
;
}
...
...
include/UInterface.h
View file @
dab976bb
...
...
@@ -25,6 +25,7 @@
#ifndef UInterface_H_
#define UInterface_H_
// ---------------------------------------------------------------------------
#include <memory>
#include <string>
#include <sstream>
#include <map>
...
...
@@ -64,7 +65,7 @@ class UInterface
{
public
:
UInterface
(
const
UniSetTypes
::
ObjectId
backid
,
CORBA
::
ORB_var
orb
=
NULL
,
UniSetTypes
::
ObjectIndex
*
oind
=
NULL
);
UInterface
(
const
UniSetTypes
::
ObjectId
backid
,
CORBA
::
ORB_var
orb
=
NULL
,
std
::
shared_ptr
<
UniSetTypes
::
ObjectIndex
>
oind
=
nullptr
);
UInterface
(
const
UniSetTypes
::
Configuration
*
uconf
=
UniSetTypes
::
conf
);
~
UInterface
();
...
...
@@ -220,7 +221,7 @@ class UInterface
// ---------------------------------------------------------------
// Получение указателей на вспомогательные классы.
inline
const
UniSetTypes
::
ObjectIndex
*
getObjectIndex
()
{
return
oind
;
}
inline
const
std
::
shared_ptr
<
UniSetTypes
::
ObjectIndex
>
getObjectIndex
()
{
return
oind
;
}
inline
const
UniSetTypes
::
Configuration
*
getConf
()
{
return
uconf
;
}
// ---------------------------------------------------------------
...
...
@@ -300,7 +301,7 @@ class UInterface
mutable
CosNaming
::
NamingContext_var
localctx
;
mutable
CORBA
::
ORB_var
orb
;
CacheOfResolve
rcache
;
UniSetTypes
::
ObjectIndex
*
oind
;
std
::
shared_ptr
<
UniSetTypes
::
ObjectIndex
>
oind
;
const
UniSetTypes
::
Configuration
*
uconf
;
};
// --------------------------------------------------------------------------
...
...
src/Interfaces/UInterface.cc
View file @
dab976bb
...
...
@@ -51,7 +51,7 @@ UInterface::UInterface( const UniSetTypes::Configuration* _uconf ):
init
();
}
// -----------------------------------------------------------------------------
UInterface
::
UInterface
(
const
ObjectId
backid
,
CORBA
::
ORB_var
orb
,
ObjectIndex
*
_oind
)
:
UInterface
::
UInterface
(
const
ObjectId
backid
,
CORBA
::
ORB_var
orb
,
shared_ptr
<
ObjectIndex
>
_oind
)
:
rep
(
UniSetTypes
::
conf
),
myid
(
backid
),
orb
(
orb
),
...
...
@@ -737,7 +737,7 @@ void UInterface::registered( const ObjectId id, const ObjectPtr oRef, bool force
if
(
CORBA
::
is_nil
(
orb
)
)
orb
=
uconf
->
getORB
();
uconf
->
iorfile
.
setIOR
(
id
,
orb
->
object_to_string
(
oRef
));
uconf
->
iorfile
->
setIOR
(
id
,
orb
->
object_to_string
(
oRef
));
return
;
}
...
...
@@ -756,7 +756,7 @@ void UInterface::unregister( const ObjectId id )throw(ORepFailed)
{
if
(
uconf
->
isLocalIOR
()
)
{
uconf
->
iorfile
.
unlinkIOR
(
id
);
uconf
->
iorfile
->
unlinkIOR
(
id
);
return
;
}
...
...
@@ -789,7 +789,7 @@ ObjectPtr UInterface::resolve( const ObjectId rid , const ObjectId node, int tim
if
(
CORBA
::
is_nil
(
orb
)
)
orb
=
uconf
->
getORB
();
string
sior
(
uconf
->
iorfile
.
getIOR
(
rid
));
string
sior
(
uconf
->
iorfile
->
getIOR
(
rid
));
if
(
!
sior
.
empty
()
)
{
CORBA
::
Object_var
nso
=
orb
->
string_to_object
(
sior
.
c_str
());
...
...
@@ -1127,7 +1127,7 @@ bool UInterface::isExist( const UniSetTypes::ObjectId id ) const
if
(
CORBA
::
is_nil
(
orb
)
)
orb
=
uconf
->
getORB
();
string
sior
(
uconf
->
iorfile
.
getIOR
(
id
)
);
string
sior
(
uconf
->
iorfile
->
getIOR
(
id
)
);
if
(
!
sior
.
empty
()
)
{
CORBA
::
Object_var
oref
=
orb
->
string_to_object
(
sior
.
c_str
());
...
...
src/Various/Configuration.cc
View file @
dab976bb
...
...
@@ -93,11 +93,6 @@ Configuration::Configuration():
Configuration
::~
Configuration
()
{
if
(
oind
!=
NULL
)
{
delete
oind
;
oind
=
0
;
}
}
// ---------------------------------------------------------------------------------
...
...
@@ -118,7 +113,7 @@ Configuration::Configuration( int argc, const char* const* argv, const string& x
initConfiguration
(
argc
,
argv
);
}
// ---------------------------------------------------------------------------------
Configuration
::
Configuration
(
int
argc
,
const
char
*
const
*
argv
,
ObjectIndex
*
_oind
,
Configuration
::
Configuration
(
int
argc
,
const
char
*
const
*
argv
,
shared_ptr
<
ObjectIndex
>
_oind
,
const
string
&
fileConf
)
:
oind
(
NULL
),
_argc
(
argc
),
...
...
@@ -152,7 +147,9 @@ Configuration::Configuration( int argc, const char* const* argv, const string& f
if
(
fileConf
.
empty
()
)
setConfFileName
();
oind
=
new
ObjectIndex_Array
(
omap
);
ObjectIndex_Array
*
_oi
=
new
ObjectIndex_Array
(
omap
);
oind
=
shared_ptr
<
ObjectIndex
>
(
_oi
);
initConfiguration
(
argc
,
argv
);
}
// ---------------------------------------------------------------------------------
...
...
@@ -161,6 +158,8 @@ void Configuration::initConfiguration( int argc, const char* const* argv )
// PassiveTimer pt(UniSetTimer::WaitUpTime);
ulogsys
<<
"*** configure from file: "
<<
fileConfName
<<
endl
;
iorfile
=
make_shared
<
IORFile
>
();
// -------------------------------------------------------------------------
xmlSensorsSec
=
0
;
xmlObjectsSec
=
0
;
...
...
@@ -205,7 +204,7 @@ void Configuration::initConfiguration( int argc, const char* const* argv )
// Init ObjectIndex interface
{
if
(
oind
==
NULL
)
if
(
oind
==
nullptr
)
{
UniXML
::
iterator
it
=
unixml
->
findNode
(
unixml
->
getFirstNode
(),
"ObjectsMap"
);
if
(
!
it
)
...
...
@@ -217,9 +216,15 @@ void Configuration::initConfiguration( int argc, const char* const* argv )
try
{
if
(
it
.
getIntProp
(
"idfromfile"
)
==
0
)
oind
=
new
ObjectIndex_XML
(
unixml
);
//(fileConfName);
{
ObjectIndex_XML
*
oi
=
new
ObjectIndex_XML
(
unixml
);
//(fileConfName);
oind
=
shared_ptr
<
ObjectIndex
>
(
oi
);
}
else
oind
=
new
ObjectIndex_idXML
(
unixml
);
//(fileConfName);
{
ObjectIndex_idXML
*
oi
=
new
ObjectIndex_idXML
(
unixml
);
//(fileConfName);
oind
=
shared_ptr
<
ObjectIndex
>
(
oi
);
}
}
catch
(
Exception
&
ex
)
{
...
...
tests/ui.cc
View file @
dab976bb
...
...
@@ -21,7 +21,7 @@ TEST_CASE("UInterface","[UInterface]")
UInterface
ui
;
CHECK
(
ui
.
getObjectIndex
()
!=
0
);
CHECK
(
ui
.
getObjectIndex
()
!=
nullptr
);
CHECK
(
ui
.
getConf
()
==
UniSetTypes
::
conf
);
CHECK
(
ui
.
getConfIOType
(
sid
)
!=
UniversalIO
::
UnknownIOType
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment