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
Stack Of Tasks
dynamic-graph
Commits
b8fa2b31
Commit
b8fa2b31
authored
14 years ago
by
Nicolas Mansard
Browse files
Options
Downloads
Patches
Plain Diff
Added a bind for commands on std::ostream.
parent
8d4bd931
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
include/dynamic-graph/command-bind.h
+71
-2
71 additions, 2 deletions
include/dynamic-graph/command-bind.h
with
71 additions
and
2 deletions
include/dynamic-graph/command-bind.h
+
71
−
2
View file @
b8fa2b31
...
@@ -136,10 +136,13 @@ namespace dynamicgraph {
...
@@ -136,10 +136,13 @@ namespace dynamicgraph {
template
<
class
E
,
typename
T
>
template
<
class
E
,
typename
T
>
CommandVoid1
<
E
,
T
>*
CommandVoid1
<
E
,
T
>*
makeCommandVoid1
(
E
&
entity
,
makeCommandVoid1
(
E
&
entity
,
typename
CommandVoid1
<
E
,
T
>::
memberFunction_t
function
,
// The following syntaxt don't compile when not specializing the template
// arg... why ???
//typename CommandVoid1<E,T>::memberFunction_t function ,
boost
::
function
<
void
(
E
*
,
const
T
&
)
>
function
,
const
std
::
string
&
docString
)
const
std
::
string
&
docString
)
{
{
return
new
CommandVoid1
<
E
,
T
>
(
entity
,
return
new
CommandVoid1
<
E
,
T
>
(
entity
,
boost
::
bind
(
function
,
&
entity
,
_1
),
docString
);
boost
::
bind
(
function
,
&
entity
,
_1
),
docString
);
}
}
...
@@ -162,4 +165,70 @@ namespace dynamicgraph {
...
@@ -162,4 +165,70 @@ namespace dynamicgraph {
}
// namespace command
}
// namespace command
}
// namespace dynamicgraph
}
// namespace dynamicgraph
/* --- FUNCTION VERBOSE ----------------------------------------------------- */
/* This bind a function void f( ostream& ) that display some results into
* a string f( void ) that return some string results. */
namespace
dynamicgraph
{
namespace
command
{
template
<
class
E
>
struct
CommandVerbose
:
public
Command
{
typedef
boost
::
function
<
void
(
std
::
ostream
&
)
>
function_t
;
typedef
boost
::
function
<
void
(
E
*
,
std
::
ostream
&
)
>
memberFunction_t
;
typedef
void
(
E
::*
memberFunctionConst_ptr_t
)
(
std
::
ostream
&
)
const
;
typedef
void
(
E
::*
memberFunction_ptr_t
)
(
std
::
ostream
&
);
CommandVerbose
(
E
&
entity
,
function_t
function
,
const
std
::
string
&
docString
)
:
Command
(
entity
,
boost
::
assign
::
list_of
(
ValueHelper
<
std
::
string
>::
TypeID
),
docString
)
,
fptr
(
function
)
{}
protected
:
virtual
Value
doExecute
()
{
assert
(
getParameterValues
().
size
()
==
0
);
std
::
ostringstream
oss
;
fptr
(
oss
);
return
Value
(
oss
.
str
()
);
// return string
}
private
:
function_t
fptr
;
};
template
<
class
E
>
CommandVerbose
<
E
>*
makeCommandVerbose
(
E
&
entity
,
//void (E::*function) (std::ostream&) const,
typename
CommandVerbose
<
E
>::
memberFunctionConst_ptr_t
function
,
const
std
::
string
&
docString
)
{
return
new
CommandVerbose
<
E
>
(
entity
,
boost
::
bind
(
function
,
&
entity
,
_1
),
docString
);
return
NULL
;
}
template
<
class
E
>
CommandVerbose
<
E
>*
makeCommandVerbose
(
E
&
entity
,
typename
CommandVerbose
<
E
>::
memberFunction_ptr_t
function
,
const
std
::
string
&
docString
)
{
return
new
CommandVerbose
<
E
>
(
entity
,
boost
::
bind
(
function
,
&
entity
,
_1
),
docString
);
return
NULL
;
}
std
::
string
docCommandVerbose
(
const
std
::
string
&
doc
)
{
return
std
::
string
(
"
\n
"
)
+
doc
+
"
\n\n
No input.
\n
Return a string.
\n\n
"
;
}
}
// namespace command
}
// namespace dynamicgraph
#endif // __dg_command_bind_h__
#endif // __dg_command_bind_h__
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