Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
dynamic-graph
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Guilhem Saurel
dynamic-graph
Commits
b7324a31
Commit
b7324a31
authored
13 years ago
by
Florent Lamiraux
Browse files
Options
Downloads
Plain Diff
Merge branch 'topic/proto-command' into topic/singleton
Conflicts: tests/entity.cpp
parents
71bf1af7
12c5bfcf
No related branches found
Branches containing commit
Tags
v2.5
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
include/dynamic-graph/entity.h
+1
-1
1 addition, 1 deletion
include/dynamic-graph/entity.h
src/dgraph/entity.cpp
+1
-4
1 addition, 4 deletions
src/dgraph/entity.cpp
tests/entity.cpp
+24
-14
24 additions, 14 deletions
tests/entity.cpp
tests/factory.cpp
+21
-1
21 additions, 1 deletion
tests/factory.cpp
with
47 additions
and
20 deletions
include/dynamic-graph/entity.h
+
1
−
1
View file @
b7324a31
...
...
@@ -71,7 +71,6 @@ namespace dynamicgraph
/// customize the command-line by overriding commandLine ().
class
DYNAMIC_GRAPH_DLLAPI
Entity
:
private
boost
::
noncopyable
{
DYNAMIC_GRAPH_ENTITY_DECL
();
public:
typedef
std
::
map
<
std
::
string
,
SignalBase
<
int
>*
>
SignalMap
;
typedef
std
::
map
<
const
std
::
string
,
command
::
Command
*>
CommandMap_t
;
...
...
@@ -83,6 +82,7 @@ namespace dynamicgraph
{
return
name
;
}
virtual
const
std
::
string
&
getClassName
()
const
=
0
;
SignalBase
<
int
>&
getSignal
(
const
std
::
string
&
signalName
);
const
SignalBase
<
int
>&
getSignal
(
const
std
::
string
&
signalName
)
const
;
...
...
This diff is collapsed.
Click to expand it.
src/dgraph/entity.cpp
+
1
−
4
View file @
b7324a31
...
...
@@ -34,9 +34,6 @@ using namespace std;
using
namespace
dynamicgraph
;
using
dynamicgraph
::
command
::
Command
;
const
std
::
string
Entity
::
CLASS_NAME
=
"Entity"
;
void
Entity
::
entityRegistration
()
{
...
...
@@ -58,7 +55,7 @@ Entity( const string& name__ )
if
(
name
.
length
()
==
0
)
{
stringstream
oss
;
oss
<<
rand
();
name
=
this
->
getClassName
();
//
name = this->getClassName();
Cannot call a virtual function from the constructor
name
+=
"::"
;
name
+=
oss
.
str
();
}
...
...
This diff is collapsed.
Click to expand it.
tests/entity.cpp
+
24
−
14
View file @
b7324a31
...
...
@@ -26,33 +26,43 @@
using
boost
::
test_tools
::
output_test_stream
;
extern
"C"
{
dynamicgraph
::
Entity
*
EntityMaker_Entity
(
const
std
::
string
&
objname
)
namespace
dynamicgraph
{
class
CustomEntity
:
public
Entity
{
return
new
dynamicgraph
::
Entity
(
objname
);
}
public:
static
const
std
::
string
CLASS_NAME
;
virtual
const
std
::
string
&
getClassName
()
const
{
return
CLASS_NAME
;
}
CustomEntity
(
const
std
::
string
n
)
:
Entity
(
n
)
{
}
};
DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN
(
CustomEntity
,
"CustomEntity"
);
}
BOOST_AUTO_TEST_CASE
(
constructor
)
{
dynamicgraph
::
FactoryStorage
::
getInstance
()
->
registerEntity
(
dynamicgraph
::
Entity
::
CLASS_NAME
,
&
EntityMaker_Entity
);
BOOST_CHECK_EQUAL
(
dynamicgraph
::
Entity
::
CLASS_NAME
,
"Entity"
);
BOOST_CHECK_EQUAL
(
dynamicgraph
::
CustomEntity
::
CLASS_NAME
,
"CustomEntity"
);
dynamicgraph
::
Entity
&
entity
=
*
dynamicgraph
::
FactoryStorage
::
getInstance
()
->
newEntity
(
"Entity"
,
*
dynamicgraph
::
FactoryStorage
::
getInstance
()
->
newEntity
(
"
Custom
Entity"
,
"my-entity"
);
BOOST_CHECK_EQUAL
(
entity
.
getName
(),
"my-entity"
);
BOOST_CHECK_EQUAL
(
entity
.
getClassName
(),
dynamicgraph
::
Entity
::
CLASS_NAME
);
BOOST_CHECK_EQUAL
(
entity
.
getClassName
(),
dynamicgraph
::
CustomEntity
::
CLASS_NAME
);
dynamicgraph
::
Entity
entity2
(
""
);
dynamicgraph
::
Custom
Entity
entity2
(
""
);
}
BOOST_AUTO_TEST_CASE
(
signal
)
{
dynamicgraph
::
Entity
&
entity
=
*
dynamicgraph
::
Factory
Storage
::
getInstance
()
->
new
Entity
(
"
E
ntity"
,
""
);
dynamicgraph
::
Pool
Storage
::
getInstance
()
->
get
Entity
(
"
my-e
ntity"
);
// Non const getter.
try
...
...
@@ -99,7 +109,7 @@ BOOST_AUTO_TEST_CASE (display)
output_test_stream
output
;
entity
.
display
(
output
);
BOOST_CHECK
(
output
.
is_equal
(
"Entity: my-entity"
));
BOOST_CHECK
(
output
.
is_equal
(
"
Custom
Entity: my-entity"
));
}
BOOST_AUTO_TEST_CASE
(
getCommandList
)
...
...
@@ -140,7 +150,7 @@ BOOST_AUTO_TEST_CASE (commandLine_print)
std
::
istringstream
args
;
entity
.
commandLine
(
"print"
,
args
,
output
);
BOOST_CHECK
(
output
.
is_equal
(
"Entity: my-entity
\n
"
));
BOOST_CHECK
(
output
.
is_equal
(
"
Custom
Entity: my-entity
\n
"
));
}
BOOST_AUTO_TEST_CASE
(
commandLine_signals
)
...
...
This diff is collapsed.
Click to expand it.
tests/factory.cpp
+
21
−
1
View file @
b7324a31
...
...
@@ -26,9 +26,29 @@
using
boost
::
test_tools
::
output_test_stream
;
namespace
dynamicgraph
{
class
CustomEntity
:
public
Entity
{
public:
static
const
std
::
string
CLASS_NAME
;
virtual
const
std
::
string
&
getClassName
()
const
{
return
CLASS_NAME
;
}
CustomEntity
(
const
std
::
string
n
)
:
Entity
(
n
)
{
}
};
const
std
::
string
CustomEntity
::
CLASS_NAME
=
"CustomEntity"
;
}
dynamicgraph
::
Entity
*
makeEntity
(
const
std
::
string
&
objectName
)
{
return
new
dynamicgraph
::
Entity
(
objectName
);
return
new
dynamicgraph
::
Custom
Entity
(
objectName
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment