Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • cberge/dynamic-graph
  • ostasse/dynamic-graph
  • gsaurel/dynamic-graph
  • stack-of-tasks/dynamic-graph
4 results
Show changes
Showing
with 2322 additions and 713 deletions
# Copyright 2010, Olivier Stasse, JRL, CNRS/AIST
#
# This file is part of dynamic-graph.
# dynamic-graph is free software: you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# dynamic-graph is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Lesser Public License for more details. You should have
# received a copy of the GNU Lesser General Public License along with
# dynamic-graph. If not, see <http://www.gnu.org/licenses/>.
# Add default script directory.
# It is used by the import directive of the sot shell to locate
# scripts.
SET(DG_IMPORT_DEFAULT_PATHS
"${CMAKE_INSTALL_PREFIX}/share/dynamic-graph/script")
CONFIGURE_FILE(
${PROJECT_NAME}/import-default-paths.h.cmake
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/import-default-paths.h)
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/import-default-paths.h
DESTINATION include/${PROJECT_NAME}
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ OWNER_WRITE
)
# Headers list.
SET(${PROJECT_NAME}_HEADERS
contiifstream.h
debug.h
dynamic-graph-api.h
entity.h
factory.h
interpreter.h
interpreter-helper.h
plugin-loader.h
pool.h
import.h
exception-abstract.h
exception-factory.h
exception-signal.h
exception-traces.h
functions.h
shell-procedure.h
signal.h
signal-array.h
signal-base.h
signal-ptr.h
signal-time-dependent.h
signal-ptr.t.cpp
signal.t.cpp
time-dependency.h
time-dependency.t.cpp
signal-caster.h
all-signals.h
tracer.h
tracer-real-time.h
)
# Recreate correct path for the headers
#--------------------------------------
SET(fullpath_${PROJECT_NAME}_HEADERS)
FOREACH(lHeader ${${PROJECT_NAME}_HEADERS})
SET(fullpath_${PROJECT_NAME}_HEADERS
${fullpath_${PROJECT_NAME}_HEADERS}
./${PROJECT_NAME}/${lHeader}
)
ENDFOREACH(lHeader)
#----------------------------------------------------
# Install procedure for the header files
#----------------------------------------------------
INSTALL(FILES ${fullpath_${PROJECT_NAME}_HEADERS}
DESTINATION include/${PROJECT_NAME}
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ OWNER_WRITE
)
// -*- mode: c++ -*-
// Copyright 2010, François Bleibel, Olivier Stasse, JRL, CNRS/AIST
// Thomas Moulard, Nicolas Mansard LAAS-CNRS
//
#ifndef DYNAMIC_GRAPH_ALL_COMMANDS_H
#define DYNAMIC_GRAPH_ALL_COMMANDS_H
// Utility header files including all commands headers
#include <dynamic-graph/command-bind.h>
#include <dynamic-graph/command-direct-getter.h>
#include <dynamic-graph/command-direct-setter.h>
#include <dynamic-graph/command-getter.h>
#include <dynamic-graph/command-setter.h>
#include <dynamic-graph/command.h>
#endif //! DYNAMIC_GRAPH_ALL_COMMANDS_H
/*
* Copyright 2010,
* François Bleibel,
* Olivier Stasse,
*
* CNRS/AIST
*
* This file is part of dynamic-graph.
* dynamic-graph is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
* dynamic-graph is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details. You should
* have received a copy of the GNU Lesser General Public License along
* with dynamic-graph. If not, see <http://www.gnu.org/licenses/>.
*/
// -*- mode: c++ -*-
// Copyright 2010, François Bleibel, Thomas Moulard, Olivier Stasse,
// JRL, CNRS/AIST.
//
#ifndef ALLSIGNALS_H_
#define ALLSIGNALS_H_
#ifndef DYNAMIC_GRAPH_ALL_SIGNALS_H
#define DYNAMIC_GRAPH_ALL_SIGNALS_H
/// Utility header files including all signal headers
// Utility header files including all signal headers
#include <dynamic-graph/signal.h>
#include <dynamic-graph/signal-ptr.h>
#include <dynamic-graph/signal-time-dependent.h>
#include <dynamic-graph/signal.h>
#endif /* ALLSIGNALS_H_ */
#endif //! DYNAMIC_GRAPH_ALL_SIGNALS_H
//
// Copyright 2010 CNRS
//
// Author: Nicolas Mansard
//
#ifndef __dg_command_bind_h__
#define __dg_command_bind_h__
/* Create a command from a bind directly. Examples are:
* addCommand("myProcVoid",
* makeCommandVoid0(*this,&ClassName::functionNoArg,
* docCommandVoid0("Simple line doc here.")));
* addCommand("myProcOneString",
* makeCommandVoid1(*this,&EntityName::functionOneStringArg,
* docCommandVoid1("Simple line doc here.",
* "string")));
*
*/
#include <boost/assign/list_of.hpp>
#include <boost/bind.hpp>
#include <boost/function.hpp>
#include "dynamic-graph/command.h"
/* --- FUNCTION 0 ARGS ----------------------------------------------------- */
namespace dynamicgraph {
namespace command {
template <class E>
struct CommandVoid0 : public Command {
CommandVoid0(E &entity, boost::function<void(void)> function,
const std::string &docString)
: Command(entity, EMPTY_ARG, docString), fptr(function) {}
protected:
virtual Value doExecute() {
assert(getParameterValues().size() == 0);
fptr();
return Value(); // void
}
private:
boost::function<void(void)> fptr;
};
template <class E>
CommandVoid0<E> *makeCommandVoid0(E &entity,
boost::function<void(void)> function,
const std::string &docString) {
return new CommandVoid0<E>(entity, function, docString);
}
template <class E>
CommandVoid0<E> *makeCommandVoid0(E &entity,
boost::function<void(E *)> function,
const std::string &docString) {
return new CommandVoid0<E>(entity, boost::bind(function, &entity), docString);
}
template <class E>
CommandVoid0<E> *makeCommandVoid0(E &entity, void (E::*function)(void),
const std::string &docString) {
return new CommandVoid0<E>(entity, boost::bind(function, &entity), docString);
}
inline std::string docCommandVoid0(const std::string &doc) {
return std::string("\n") + doc + "\n\nNo input.\nVoid return.\n\n";
}
} // namespace command
} // namespace dynamicgraph
/* --- FUNCTION 1 ARGS ------------------------------------------------------ */
namespace dynamicgraph {
namespace command {
template <class E, typename T>
struct CommandVoid1 : public Command {
typedef boost::function<void(const T &)> function_t;
CommandVoid1(E &entity, function_t function, const std::string &docString)
: Command(entity, boost::assign::list_of(ValueHelper<T>::TypeID),
docString),
fptr(function) {}
protected:
virtual Value doExecute() {
assert(getParameterValues().size() == 1);
T val = getParameterValues()[0].value();
fptr(val);
return Value(); // void
}
private:
function_t fptr;
};
template <class E, typename T>
CommandVoid1<E, T> *makeCommandVoid1(
E &entity, boost::function<void(const T &)> function,
// typename CommandVoid1<E,T>::function_t function ,
const std::string &docString) {
return new CommandVoid1<E, T>(entity, function, docString);
}
template <class E, typename T>
CommandVoid1<E, T> *makeCommandVoid1(
E &entity,
// The following syntaxt don't compile when not specializing
// the template arg... why ???
boost::function<void(E *, const T &)> function,
const std::string &docString) {
return new CommandVoid1<E, T>(entity, boost::bind(function, &entity, _1),
docString);
}
template <class E, typename T>
CommandVoid1<E, T> *makeCommandVoid1(E &entity, void (E::*function)(const T &),
const std::string &docString) {
return new CommandVoid1<E, T>(entity, boost::bind(function, &entity, _1),
docString);
return NULL;
}
inline std::string docCommandVoid1(const std::string &doc,
const std::string &type) {
return std::string("\n") + doc + "\n\nInput:\n - A " + type +
".\nVoid return.\n\n";
}
} // namespace command
} // namespace dynamicgraph
/* --- FUNCTION 2 ARGS ------------------------------------------------------ */
namespace dynamicgraph {
namespace command {
template <class E, typename T1, typename T2>
struct CommandVoid2 : public Command {
typedef boost::function<void(const T1 &, const T2 &)> function_t;
CommandVoid2(E &entity, function_t function, const std::string &docString)
: Command(entity,
boost::assign::list_of(ValueHelper<T1>::TypeID)(
ValueHelper<T2>::TypeID),
docString),
fptr(function) {}
protected:
virtual Value doExecute() {
assert(getParameterValues().size() == 2);
T1 val1 = getParameterValues()[0].value();
T2 val2 = getParameterValues()[1].value();
fptr(val1, val2);
return Value(); // void
}
private:
function_t fptr;
};
template <class E, typename T1, typename T2>
CommandVoid2<E, T1, T2> *makeCommandVoid2(
E &entity, boost::function<void(const T1 &, const T2 &)> function,
const std::string &docString) {
return new CommandVoid2<E, T1, T2>(entity, function, docString);
}
template <class E, typename T1, typename T2>
CommandVoid2<E, T1, T2> *makeCommandVoid2(
E &entity,
// The following syntaxt don't compile when not specializing
// the template arg... why ???
boost::function<void(E *, const T1 &, const T2 &)> function,
const std::string &docString) {
return new CommandVoid2<E, T1, T2>(
entity, boost::bind(function, &entity, _1, _2), docString);
}
template <class E, typename T1, typename T2>
CommandVoid2<E, T1, T2> *makeCommandVoid2(E &entity,
void (E::*function)(const T1 &,
const T2 &),
const std::string &docString) {
return new CommandVoid2<E, T1, T2>(
entity, boost::bind(function, &entity, _1, _2), docString);
return NULL;
}
inline std::string docCommandVoid2(const std::string &doc,
const std::string &type1,
const std::string &type2) {
return (std::string("\n") + doc + "\n\n" + "Input:\n - A " + type1 + ".\n" +
"Input:\n - A " + type2 + ".\n" + "Void return.\n\n");
}
} // namespace command
} // namespace dynamicgraph
/* --- FUNCTION 3 ARGS ------------------------------------------------------ */
namespace dynamicgraph {
namespace command {
template <class E, typename T1, typename T2, typename T3>
struct CommandVoid3 : public Command {
typedef boost::function<void(const T1 &, const T2 &, const T3 &)> function_t;
CommandVoid3(E &entity, function_t function, const std::string &docString)
: Command(entity,
boost::assign::list_of(ValueHelper<T1>::TypeID)(
ValueHelper<T2>::TypeID)(ValueHelper<T3>::TypeID),
docString),
fptr(function) {}
protected:
virtual Value doExecute() {
assert(getParameterValues().size() == 3);
T1 val1 = getParameterValues()[0].value();
T2 val2 = getParameterValues()[1].value();
T3 val3 = getParameterValues()[2].value();
fptr(val1, val2, val3);
return Value(); // void
}
private:
function_t fptr;
};
template <class E, typename T1, typename T2, typename T3>
CommandVoid3<E, T1, T2, T3> *makeCommandVoid3(
E &entity, typename CommandVoid3<E, T1, T2, T3>::function_t function,
const std::string &docString) {
return new CommandVoid3<E, T1, T2, T3>(entity, function, docString);
}
template <class E, typename T1, typename T2, typename T3>
CommandVoid3<E, T1, T2, T3> *makeCommandVoid3(
E &entity,
// The following syntaxt don't compile when not specializing the template
// arg... why ???
boost::function<void(E *, const T1 &, const T2 &, const T3 &)> function,
const std::string &docString) {
return new CommandVoid3<E, T1, T2, T3>(
entity, boost::bind(function, &entity, _1, _2, _3), docString);
}
template <class E, typename T1, typename T2, typename T3>
CommandVoid3<E, T1, T2, T3> *makeCommandVoid3(
E &entity, void (E::*function)(const T1 &, const T2 &, const T3 &),
const std::string &docString) {
return new CommandVoid3<E, T1, T2, T3>(
entity, boost::bind(function, &entity, _1, _2, _3), docString);
return NULL;
}
inline std::string docCommandVoid3(const std::string &doc,
const std::string &type1,
const std::string &type2,
const std::string &type3) {
return (std::string("\n") + doc + "\n\n" + "Input:\n - A " + type1 + ".\n" +
"Input:\n - A " + type2 + ".\n" + "Input:\n - A " + type3 + ".\n" +
"Void return.\n\n");
}
} // namespace command
} // namespace dynamicgraph
/* --- FUNCTION 4 ARGS ------------------------------------------------------ */
namespace dynamicgraph {
namespace command {
template <class E, typename T1, typename T2, typename T3, typename T4>
struct CommandVoid4 : public Command {
typedef boost::function<void(const T1 &, const T2 &, const T3 &, const T4 &)>
function_t;
typedef void (E::*memberFunction_ptr_t)(const T1 &, const T2 &, const T3 &,
const T4 &);
CommandVoid4(E &entity, function_t function, const std::string &docString)
: Command(entity,
boost::assign::list_of(ValueHelper<T1>::TypeID)(
ValueHelper<T2>::TypeID)(ValueHelper<T3>::TypeID)(
ValueHelper<T4>::TypeID),
docString),
fptr(function) {}
protected:
virtual Value doExecute() {
assert(getParameterValues().size() == 4);
T1 val1 = getParameterValues()[0].value();
T2 val2 = getParameterValues()[1].value();
T3 val3 = getParameterValues()[2].value();
T4 val4 = getParameterValues()[3].value();
fptr(val1, val2, val3, val4);
return Value(); // void
}
private:
function_t fptr;
};
template <class E, typename T1, typename T2, typename T3, typename T4>
CommandVoid4<E, T1, T2, T3, T4> *makeCommandVoid4(
E &entity, typename CommandVoid4<E, T1, T2, T3, T4>::function_t function,
const std::string &docString) {
return new CommandVoid4<E, T1, T2, T3, T4>(entity, function, docString);
}
template <class E, typename T1, typename T2, typename T3, typename T4>
CommandVoid4<E, T1, T2, T3, T4> *makeCommandVoid4(
E &entity,
boost::function<void(E *, const T1 &, const T2 &, const T3 &, const T4 &)>
function,
const std::string &docString) {
return new CommandVoid4<E, T1, T2, T3, T4>(
entity, boost::bind(function, &entity, _1, _2, _3, _4), docString);
}
template <class E, typename T1, typename T2, typename T3, typename T4>
CommandVoid4<E, T1, T2, T3, T4> *makeCommandVoid4(
E &entity,
void (E::*function)(const T1 &, const T2 &, const T3 &, const T4 &),
const std::string &docString) {
return new CommandVoid4<E, T1, T2, T3, T4>(
entity, boost::bind(function, &entity, _1, _2, _3, _4), docString);
return NULL;
}
inline std::string docCommandVoid4(const std::string &doc,
const std::string &type1,
const std::string &type2,
const std::string &type3,
const std::string &type4) {
return (std::string("\n") + doc + "\n\n" + "Input:\n - A " + type1 + ".\n" +
"Input:\n - A " + type2 + ".\n" + "Input:\n - A " + type3 + ".\n" +
"Input:\n - A " + type4 + ".\n" + "Void return.\n\n");
}
} // namespace command
} // namespace dynamicgraph
/* --- FUNCTION 5 ARGS ------------------------------------------------------ */
namespace dynamicgraph {
namespace command {
template <class E, typename T1, typename T2, typename T3, typename T4,
typename T5>
struct CommandVoid5 : public Command {
typedef boost::function<void(const T1 &, const T2 &, const T3 &, const T4 &,
const T5 &)>
function_t;
typedef void (E::*memberFunction_ptr_t)(const T1 &, const T2 &, const T3 &,
const T4 &, const T5 &);
CommandVoid5(E &entity, function_t function, const std::string &docString)
: Command(entity,
boost::assign::list_of(ValueHelper<T1>::TypeID)(
ValueHelper<T2>::TypeID)(ValueHelper<T3>::TypeID)(
ValueHelper<T4>::TypeID)(ValueHelper<T5>::TypeID),
docString),
fptr(function) {}
protected:
virtual Value doExecute() {
assert(getParameterValues().size() == 5);
T1 val1 = getParameterValues()[0].value();
T2 val2 = getParameterValues()[1].value();
T3 val3 = getParameterValues()[2].value();
T4 val4 = getParameterValues()[3].value();
T5 val5 = getParameterValues()[4].value();
fptr(val1, val2, val3, val4, val5);
return Value(); // void
}
private:
function_t fptr;
};
template <class E, typename T1, typename T2, typename T3, typename T4,
typename T5>
CommandVoid5<E, T1, T2, T3, T4, T5> *makeCommandVoid5(
E &entity,
typename CommandVoid5<E, T1, T2, T3, T4, T5>::function_t function,
const std::string &docString) {
return new CommandVoid5<E, T1, T2, T3, T4, T5>(entity, function, docString);
}
template <class E, typename T1, typename T2, typename T3, typename T4,
typename T5>
CommandVoid5<E, T1, T2, T3, T4, T5> *makeCommandVoid5(
E &entity,
boost::function<void(E *, const T1 &, const T2 &, const T3 &, const T4 &,
const T5 &)>
function,
const std::string &docString) {
return new CommandVoid5<E, T1, T2, T3, T4, T5>(
entity, boost::bind(function, &entity, _1, _2, _3, _4, _5), docString);
}
template <class E, typename T1, typename T2, typename T3, typename T4,
typename T5>
CommandVoid5<E, T1, T2, T3, T4, T5> *makeCommandVoid5(
E &entity,
void (E::*function)(const T1 &, const T2 &, const T3 &, const T4 &,
const T5 &),
const std::string &docString) {
return new CommandVoid5<E, T1, T2, T3, T4, T5>(
entity, boost::bind(function, &entity, _1, _2, _3, _4, _5), docString);
return NULL;
}
inline std::string docCommandVoid5(const std::string &doc,
const std::string &type1,
const std::string &type2,
const std::string &type3,
const std::string &type4,
const std::string &type5) {
return (std::string("\n") + doc + "\n\n" + "Input:\n - A " + type1 + ".\n" +
"Input:\n - A " + type2 + ".\n" + "Input:\n - A " + type3 + ".\n" +
"Input:\n - A " + type4 + ".\n" + "Input:\n - A " + type5 + ".\n" +
"Void return.\n\n");
}
} // namespace command
} // namespace dynamicgraph
/* --- FUNCTION 6 ARGS ------------------------------------------------------ */
namespace dynamicgraph {
namespace command {
template <class E, typename T1, typename T2, typename T3, typename T4,
typename T5, typename T6>
struct CommandVoid6 : public Command {
typedef boost::function<void(const T1 &, const T2 &, const T3 &, const T4 &,
const T5 &, const T6 &)>
function_t;
typedef void (E::*memberFunction_ptr_t)(const T1 &, const T2 &, const T3 &,
const T4 &, const T5 &, const T6 &);
CommandVoid6(E &entity, function_t function, const std::string &docString)
: Command(entity,
boost::assign::list_of(ValueHelper<T1>::TypeID)(
ValueHelper<T2>::TypeID)(ValueHelper<T3>::TypeID)(
ValueHelper<T4>::TypeID)(ValueHelper<T5>::TypeID)(
ValueHelper<T6>::TypeID),
docString),
fptr(function) {}
protected:
virtual Value doExecute() {
assert(getParameterValues().size() == 6);
T1 val1 = getParameterValues()[0].value();
T2 val2 = getParameterValues()[1].value();
T3 val3 = getParameterValues()[2].value();
T4 val4 = getParameterValues()[3].value();
T5 val5 = getParameterValues()[4].value();
T6 val6 = getParameterValues()[5].value();
fptr(val1, val2, val3, val4, val5, val6);
return Value(); // void
}
private:
function_t fptr;
};
template <class E, typename T1, typename T2, typename T3, typename T4,
typename T5, typename T6>
CommandVoid6<E, T1, T2, T3, T4, T5, T6> *makeCommandVoid6(
E &entity,
typename CommandVoid6<E, T1, T2, T3, T4, T5, T6>::function_t function,
const std::string &docString) {
return new CommandVoid6<E, T1, T2, T3, T4, T5, T6>(entity, function,
docString);
}
template <class E, typename T1, typename T2, typename T3, typename T4,
typename T5, typename T6>
CommandVoid6<E, T1, T2, T3, T4, T5, T6> *makeCommandVoid6(
E &entity,
boost::function<void(E *, const T1 &, const T2 &, const T3 &, const T4 &,
const T5 &, const T6 &)>
function,
const std::string &docString) {
return new CommandVoid6<E, T1, T2, T3, T4, T5, T6>(
entity, boost::bind(function, &entity, _1, _2, _3, _4, _5, _6),
docString);
}
template <class E, typename T1, typename T2, typename T3, typename T4,
typename T5, typename T6>
CommandVoid6<E, T1, T2, T3, T4, T5, T6> *makeCommandVoid6(
E &entity,
void (E::*function)(const T1 &, const T2 &, const T3 &, const T4 &,
const T5 &, const T6 &),
const std::string &docString) {
return new CommandVoid6<E, T1, T2, T3, T4, T5, T6>(
entity, boost::bind(function, &entity, _1, _2, _3, _4, _5, _6),
docString);
return NULL;
}
inline std::string docCommandVoid6(
const std::string &doc, const std::string &type1, const std::string &type2,
const std::string &type3, const std::string &type4,
const std::string &type5, const std::string &type6) {
return (std::string("\n") + doc + "\n\n" + "Input:\n - A " + type1 + ".\n" +
"Input:\n - A " + type2 + ".\n" + "Input:\n - A " + type3 + ".\n" +
"Input:\n - A " + type4 + ".\n" + "Input:\n - A " + type5 + ".\n" +
"Input:\n - A " + type6 + ".\n" + "Void return.\n\n");
}
} // namespace command
} // namespace dynamicgraph
/* --- FUNCTION 7 ARGS ------------------------------------------------------ */
namespace dynamicgraph {
namespace command {
template <class E, typename T1, typename T2, typename T3, typename T4,
typename T5, typename T6, typename T7>
struct CommandVoid7 : public Command {
typedef boost::function<void(const T1 &, const T2 &, const T3 &, const T4 &,
const T5 &, const T6 &, const T7 &)>
function_t;
typedef void (E::*memberFunction_ptr_t)(const T1 &, const T2 &, const T3 &,
const T4 &, const T5 &, const T6 &,
const T7 &);
CommandVoid7(E &entity, function_t function, const std::string &docString)
: Command(entity,
boost::assign::list_of(ValueHelper<T1>::TypeID)(
ValueHelper<T2>::TypeID)(ValueHelper<T3>::TypeID)(
ValueHelper<T4>::TypeID)(ValueHelper<T5>::TypeID)(
ValueHelper<T6>::TypeID)(ValueHelper<T7>::TypeID),
docString),
fptr(function) {}
protected:
virtual Value doExecute() {
assert(getParameterValues().size() == 7);
T1 val1 = getParameterValues()[0].value();
T2 val2 = getParameterValues()[1].value();
T3 val3 = getParameterValues()[2].value();
T4 val4 = getParameterValues()[3].value();
T5 val5 = getParameterValues()[4].value();
T6 val6 = getParameterValues()[5].value();
T7 val7 = getParameterValues()[6].value();
fptr(val1, val2, val3, val4, val5, val6, val7);
return Value(); // void
}
private:
function_t fptr;
};
template <class E, typename T1, typename T2, typename T3, typename T4,
typename T5, typename T6, typename T7>
CommandVoid7<E, T1, T2, T3, T4, T5, T6, T7> *makeCommandVoid7(
E &entity,
typename CommandVoid7<E, T1, T2, T3, T4, T5, T6, T7>::function_t function,
const std::string &docString) {
return new CommandVoid7<E, T1, T2, T3, T4, T5, T6, T7>(entity, function,
docString);
}
template <class E, typename T1, typename T2, typename T3, typename T4,
typename T5, typename T6, typename T7>
CommandVoid7<E, T1, T2, T3, T4, T5, T6, T7> *makeCommandVoid7(
E &entity,
boost::function<void(E *, const T1 &, const T2 &, const T3 &, const T4 &,
const T5 &, const T6 &, const T7 &)>
function,
const std::string &docString) {
return new CommandVoid7<E, T1, T2, T3, T4, T5, T6, T7>(
entity, boost::bind(function, &entity, _1, _2, _3, _4, _5, _6, _7),
docString);
}
template <class E, typename T1, typename T2, typename T3, typename T4,
typename T5, typename T6, typename T7>
CommandVoid7<E, T1, T2, T3, T4, T5, T6, T7> *makeCommandVoid7(
E &entity,
void (E::*function)(const T1 &, const T2 &, const T3 &, const T4 &,
const T5 &, const T6 &, const T7 &),
const std::string &docString) {
return new CommandVoid7<E, T1, T2, T3, T4, T5, T6, T7>(
entity, boost::bind(function, &entity, _1, _2, _3, _4, _5, _6, _7),
docString);
return NULL;
}
inline std::string docCommandVoid7(
const std::string &doc, const std::string &type1, const std::string &type2,
const std::string &type3, const std::string &type4,
const std::string &type5, const std::string &type6,
const std::string &type7) {
return (std::string("\n") + doc + "\n\n" + "Input:\n - A " + type1 + ".\n" +
"Input:\n - A " + type2 + ".\n" + "Input:\n - A " + type3 + ".\n" +
"Input:\n - A " + type4 + ".\n" + "Input:\n - A " + type5 + ".\n" +
"Input:\n - A " + type6 + ".\n" + "Input:\n - A " + type7 + ".\n" +
"Void return.\n\n");
}
} // namespace command
} // namespace dynamicgraph
/* --- FUNCTION 8 ARGS ------------------------------------------------------ */
namespace dynamicgraph {
namespace command {
template <class E, typename T1, typename T2, typename T3, typename T4,
typename T5, typename T6, typename T7, typename T8>
struct CommandVoid8 : public Command {
typedef boost::function<void(const T1 &, const T2 &, const T3 &, const T4 &,
const T5 &, const T6 &, const T7 &, const T8 &)>
function_t;
typedef void (E::*memberFunction_ptr_t)(const T1 &, const T2 &, const T3 &,
const T4 &, const T5 &, const T6 &,
const T7 &, const T8 &);
CommandVoid8(E &entity, function_t function, const std::string &docString)
: Command(entity,
boost::assign::list_of(ValueHelper<T1>::TypeID)(
ValueHelper<T2>::TypeID)(ValueHelper<T3>::TypeID)(
ValueHelper<T4>::TypeID)(ValueHelper<T5>::TypeID)(
ValueHelper<T6>::TypeID)(ValueHelper<T7>::TypeID)(
ValueHelper<T8>::TypeID),
docString),
fptr(function) {}
protected:
virtual Value doExecute() {
assert(getParameterValues().size() == 8);
T1 val1 = getParameterValues()[0].value();
T2 val2 = getParameterValues()[1].value();
T3 val3 = getParameterValues()[2].value();
T4 val4 = getParameterValues()[3].value();
T5 val5 = getParameterValues()[4].value();
T6 val6 = getParameterValues()[5].value();
T7 val7 = getParameterValues()[6].value();
T8 val8 = getParameterValues()[7].value();
fptr(val1, val2, val3, val4, val5, val6, val7, val8);
return Value(); // void
}
private:
function_t fptr;
};
template <class E, typename T1, typename T2, typename T3, typename T4,
typename T5, typename T6, typename T7, typename T8>
CommandVoid8<E, T1, T2, T3, T4, T5, T6, T7, T8> *makeCommandVoid8(
E &entity,
typename CommandVoid8<E, T1, T2, T3, T4, T5, T6, T7, T8>::function_t
function,
const std::string &docString) {
return new CommandVoid8<E, T1, T2, T3, T4, T5, T6, T7, T8>(entity, function,
docString);
}
template <class E, typename T1, typename T2, typename T3, typename T4,
typename T5, typename T6, typename T7, typename T8>
CommandVoid8<E, T1, T2, T3, T4, T5, T6, T7, T8> *makeCommandVoid8(
E &entity,
boost::function<void(E *, const T1 &, const T2 &, const T3 &, const T4 &,
const T5 &, const T6 &, const T7 &, const T8 &)>
function,
const std::string &docString) {
return new CommandVoid8<E, T1, T2, T3, T4, T5, T6, T7, T8>(
entity, boost::bind(function, &entity, _1, _2, _3, _4, _5, _6, _7, _8),
docString);
}
template <class E, typename T1, typename T2, typename T3, typename T4,
typename T5, typename T6, typename T7, typename T8>
CommandVoid8<E, T1, T2, T3, T4, T5, T6, T7, T8> *makeCommandVoid8(
E &entity,
void (E::*function)(const T1 &, const T2 &, const T3 &, const T4 &,
const T5 &, const T6 &, const T7 &, const T8 &),
const std::string &docString) {
return new CommandVoid8<E, T1, T2, T3, T4, T5, T6, T7, T8>(
entity, boost::bind(function, &entity, _1, _2, _3, _4, _5, _6, _7, _8),
docString);
return NULL;
}
inline std::string docCommandVoid8(
const std::string &doc, const std::string &type1, const std::string &type2,
const std::string &type3, const std::string &type4,
const std::string &type5, const std::string &type6,
const std::string &type7, const std::string &type8) {
return (std::string("\n") + doc + "\n\n" + "Input:\n - A " + type1 + ".\n" +
"Input:\n - A " + type2 + ".\n" + "Input:\n - A " + type3 + ".\n" +
"Input:\n - A " + type4 + ".\n" + "Input:\n - A " + type5 + ".\n" +
"Input:\n - A " + type6 + ".\n" + "Input:\n - A " + type7 + ".\n" +
"Input:\n - A " + type8 + ".\n" + "Void return.\n\n");
}
} // namespace command
} // 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;
CommandVerbose(E &entity, function_t function, const std::string &docString)
: Command(entity, EMPTY_ARG, 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, typename CommandVerbose<E>::function_t function,
const std::string &docString) {
return new CommandVerbose<E>(entity, function, docString);
return NULL;
}
template <class E>
CommandVerbose<E> *makeCommandVerbose(E &entity,
void (E::*function)(std::ostream &),
const std::string &docString) {
return new CommandVerbose<E>(entity, boost::bind(function, &entity, _1),
docString);
return NULL;
}
inline std::string docCommandVerbose(const std::string &doc) {
return std::string("\n") + doc + "\n\nNo input.\n Return a string.\n\n";
}
/*************************/
/* Template return types */
/*************************/
template <class E, class ReturnType>
struct CommandReturnType0 : public Command {
CommandReturnType0(E &entity, boost::function<ReturnType(void)> function,
const std::string &docString)
: Command(entity, EMPTY_ARG, docString), fptr(function) {}
protected:
virtual Value doExecute() {
assert(getParameterValues().size() == 0);
Value res(fptr());
return res;
}
private:
boost::function<ReturnType(void)> fptr;
};
template <class E, class ReturnType>
CommandReturnType0<E, ReturnType> *makeCommandReturnType0(
E &entity, boost::function<ReturnType(void)> function,
const std::string &docString) {
return new CommandReturnType0<E, ReturnType>(entity, function, docString);
}
template <class E, class ReturnType>
CommandReturnType0<E, ReturnType> *makeCommandReturnType0(
E &entity, boost::function<ReturnType(E *)> function,
const std::string &docString) {
return new CommandReturnType0<E, ReturnType>(
entity, boost::bind(function, &entity), docString);
}
template <class E, class ReturnType>
CommandReturnType0<E, ReturnType> *makeCommandReturnType0(
E &entity, ReturnType (E::*function)(void), const std::string &docString) {
return new CommandReturnType0<E, ReturnType>(
entity, boost::bind(function, &entity), docString);
}
template <typename ReturnType>
inline std::string docCommandReturnType0(
const std::string &doc, const std::string & /* return_type */) {
return std::string("\n") + doc + "\n\nNo input.\n" +
typeid(ReturnType).name() + " return.\n\n";
}
} // namespace command
} // namespace dynamicgraph
/* --- FUNCTION 1 ARGS ------------------------------------------------------ */
namespace dynamicgraph {
namespace command {
template <class E, typename ReturnType, typename T>
struct CommandReturnType1 : public Command {
typedef boost::function<ReturnType(const T &)> function_t;
CommandReturnType1(E &entity, function_t function,
const std::string &docString)
: Command(entity, boost::assign::list_of(ValueHelper<T>::TypeID),
docString),
fptr(function) {}
protected:
virtual Value doExecute() {
assert(getParameterValues().size() == 1);
T val = getParameterValues()[0].value();
Value res(fptr(val));
return res;
}
private:
function_t fptr;
};
template <class E, typename ReturnType, typename T>
CommandReturnType1<E, ReturnType, T> *makeCommandReturnType1(
E &entity, boost::function<ReturnType(const T &)> function,
const std::string &docString) {
return new CommandReturnType1<E, ReturnType, T>(entity, function, docString);
}
template <class E, typename ReturnType, typename T>
CommandReturnType1<E, ReturnType, T> *makeCommandReturnType1(
E &entity,
// The following syntaxt don't compile when not
// specializing the template arg... why ???
boost::function<ReturnType(E *, const T &)> function,
const std::string &docString) {
return new CommandReturnType1<E, ReturnType, T>(
entity, boost::bind(function, &entity, _1), docString);
}
template <class E, typename ReturnType, typename T>
CommandReturnType1<E, ReturnType, T> *makeCommandReturnType1(
E &entity, ReturnType (E::*function)(const T &),
const std::string &docString) {
return new CommandReturnType1<E, ReturnType, T>(
entity, boost::bind(function, &entity, _1), docString);
return NULL;
}
template <typename ReturnType>
inline std::string docCommandReturnType1(const std::string &doc,
const std::string &type) {
return std::string("\n") + doc + "\n\nInput:\n - A " + type + ".\n" +
typeid(ReturnType).name() + "return.\n\n";
}
} // namespace command
} // namespace dynamicgraph
/*********** FUNCTION 2 Arguments ************************/
namespace dynamicgraph {
namespace command {
template <class E, typename ReturnType, typename T1, typename T2>
struct CommandReturnType2 : public Command {
typedef boost::function<ReturnType(const T1 &, const T2 &)> function_t;
CommandReturnType2(E &entity, function_t function,
const std::string &docString)
: Command(entity,
boost::assign::list_of(ValueHelper<T1>::TypeID)(
ValueHelper<T2>::TypeID),
docString),
fptr(function) {}
protected:
virtual Value doExecute() {
assert(getParameterValues().size() == 2);
T1 val1 = getParameterValues()[0].value();
T2 val2 = getParameterValues()[1].value();
Value res(fptr(val1, val2));
return res;
}
private:
function_t fptr;
};
template <class E, typename ReturnType, typename T1, typename T2>
CommandReturnType2<E, ReturnType, T1, T2> *makeCommandReturnType2(
E &entity, boost::function<ReturnType(const T1 &, const T2 &)> function,
const std::string &docString) {
return new CommandReturnType2<E, ReturnType, T1, T2>(entity, function,
docString);
}
template <class E, typename ReturnType, typename T1, typename T2>
CommandReturnType2<E, ReturnType, T1, T2> *makeCommandReturnType2(
E &entity,
// The following syntaxt don't compile when not specializing the template
// arg... why ???
boost::function<ReturnType(E *, const T1 &, const T2 &)> function,
const std::string &docString) {
return new CommandReturnType2<E, ReturnType, T1, T2>(
entity, boost::bind(function, &entity, _1, _2), docString);
}
template <class E, typename ReturnType, typename T1, typename T2>
CommandReturnType2<E, ReturnType, T1, T2> *makeCommandReturnType2(
E &entity, ReturnType (E::*function)(const T1 &, const T2 &),
const std::string &docString) {
return new CommandReturnType2<E, ReturnType, T1, T2>(
entity, boost::bind(function, &entity, _1, _2), docString);
return NULL;
}
template <typename ReturnType>
inline std::string docCommandReturnType2(const std::string &doc,
const std::string &type1,
const std::string &type2) {
return (std::string("\n") + doc + "\n\n" + "Input:\n - A " + type1 + ".\n" +
"Input:\n - A " + type2 + ".\n" +
"ReturnType:\n - Returns:" + typeid(ReturnType).name() + +".\n\n");
}
} // namespace command
} // namespace dynamicgraph
#endif // __dg_command_bind_h__
//
// Copyright 2010 CNRS
//
// Author: Nicolas Mansard
//
#ifndef __dg_command_direct_getter_h__
#define __dg_command_direct_getter_h__
/* Define a getter command directly on the attribute (no need to pass by
* an explicit function). A typical use is given here:
* addCommand("getSize",
* makeDirectGetter(*this,&_dimension,
* docDirectGetter("dimension","int")));
*
*/
#include <boost/assign/list_of.hpp>
#include "dynamic-graph/command.h"
/* --- GETTER --------------------------------------------------------- */
namespace dynamicgraph {
namespace command {
template <class E, typename T>
class DirectGetter : public Command {
public:
/// Pointer to method that sets parameter of type T
typedef T (E::*GetterMethod)() const;
/// Constructor
DirectGetter(E &entity, T *ptr, const std::string &docString)
: Command(entity, std::vector<Value::Type>(), docString), T_ptr(ptr) {}
protected:
virtual Value doExecute() { return Value(*T_ptr); }
private:
T *T_ptr;
};
template <class E, typename T>
DirectGetter<E, T> *makeDirectGetter(E &entity, T *ptr,
const std::string &docString) {
return new DirectGetter<E, T>(entity, ptr, docString);
}
inline std::string docDirectGetter(const std::string &name,
const std::string &type) {
return std::string("\nGet the ") + name + ".\n\nNo input.\nReturn an " +
type + ".\n\n";
}
} // namespace command
} // namespace dynamicgraph
#endif // __dg_command_direct_getter_h__
//
// Copyright 2010 CNRS
//
// Author: Nicolas Mansard
//
#ifndef __dg_command_direct_setter_h__
#define __dg_command_direct_setter_h__
/* Define a setter command directly on the attribute (no need to pass by
* an explicit function). A typical use is given here:
* addCommand("setSize",
* makeDirectSetter(*this,&_dimension,
* docDirectSetter("dimension","int")));
*
*/
#include <boost/assign/list_of.hpp>
#include "dynamic-graph/command.h"
/* --- SETTER --------------------------------------------------------- */
namespace dynamicgraph {
namespace command {
template <class E, typename T>
class DirectSetter : public Command {
public:
DirectSetter(E &entity, T *ptr, const std::string &docString)
: Command(entity, boost::assign::list_of(ValueHelper<T>::TypeID),
docString),
T_ptr(ptr) {}
protected:
virtual Value doExecute() {
const std::vector<Value> &values = getParameterValues();
T val = values[0].value();
(*T_ptr) = val;
return Value(); // void
}
private:
T *T_ptr;
};
template <class E, typename T>
DirectSetter<E, T> *makeDirectSetter(E &entity, T *ptr,
const std::string &docString) {
return new DirectSetter<E, T>(entity, ptr, docString);
}
inline std::string docDirectSetter(const std::string &name,
const std::string &type) {
return std::string("\nSet the ") + name + ".\n\nInput:\n - a " + type +
".\nVoid return.\n\n";
}
} // namespace command
} // namespace dynamicgraph
#endif // __dg_command_direct_setter_h__
//
// Copyright 2010 CNRS
//
// Author: Florent Lamiraux
//
#ifndef DYNAMIC_GRAPH_COMMAND_GETTER_H
#define DYNAMIC_GRAPH_COMMAND_GETTER_H
#include "dynamic-graph/command.h"
namespace dynamicgraph {
namespace command {
///
/// Command that calls a parameter getter function
///
/// This class is templated by a type E deriving from entity and
/// a type T of data.
///
/// Let us assume that class E has a private member of type T and a
/// public getter function for this member:
/// \code
/// class E : public Entity
/// {
/// public:
/// E (const std::string& inName) : Entity(inName) {}
/// T getParameter() const {return parameter_;}
/// private:
/// T parameter_;
/// };
/// \endcode
/// Then the command defined by:
/// \code
/// E entity("MyEntity");
/// Getter<E,T> command(entity, &E::getParameter)
/// \endcode
/// returns the value of <c>entity.parameter_</c> upon invocation.
///
/// \note
/// \li T should be a type supported by class Value,
/// \li prototype of E::getParameter should be exactly as specified in this
/// example.
template <class E, typename T>
class Getter : public Command {
public:
/// Pointer to method that sets parameter of type T
typedef T (E::*GetterMethod)() const;
/// Constructor
Getter(E &entity, GetterMethod getterMethod, const std::string &docString);
protected:
virtual Value doExecute();
private:
GetterMethod getterMethod_;
};
} // namespace command
} // namespace dynamicgraph
#include "dynamic-graph/command-getter.t.cpp"
#endif // DYNAMIC_GRAPH_COMMAND_GETTER_H
//
// Copyright 2010 CNRS
//
// Author: Florent Lamiraux
//
#ifndef DYNAMIC_GRAPH_COMMAND_GETTER_T_CPP
#define DYNAMIC_GRAPH_COMMAND_GETTER_T_CPP
#include "dynamic-graph/command-getter.h"
#include <sstream>
namespace dynamicgraph {
class Entity;
namespace command {
template <class E, typename T>
Getter<E, T>::Getter(E &entity, GetterMethod getterMethod,
const std::string &docstring)
: Command(entity, std::vector<Value::Type>(), docstring),
getterMethod_(getterMethod) {}
template <class E, typename T>
Value Getter<E, T>::doExecute() {
E &entity = static_cast<E &>(owner());
T value = (entity.*getterMethod_)();
return Value(value);
}
} // namespace command
} // namespace dynamicgraph
#endif // DYNAMIC_GRAPH_COMMAND_GETTER_T_CPP
//
// Copyright 2010 CNRS
//
// Author: Florent Lamiraux
//
#ifndef DYNAMIC_GRAPH_COMMAND_SETTER_H
#define DYNAMIC_GRAPH_COMMAND_SETTER_H
#include "dynamic-graph/command.h"
namespace dynamicgraph {
namespace command {
///
/// Command that calls a parameter setter function
///
/// This class is templated by a type E deriving from entity and
/// a type T of data.
///
/// Let us assume that class E has a private member of type T and a
/// public setter function for this member:
/// \code
/// class E : public Entity
/// {
/// public:
/// E (const std::string& inName) : Entity(inName) {}
/// void setParameter(const T& parameter) {parameter_ = parameter;}
/// private:
/// T parameter_;
/// };
/// \endcode
/// Then the command defined by:
/// \code
/// E entity("MyEntity");
/// Setter<E,T> command(entity, &E::getParameter)
/// \endcode
/// sets the value of <c>entity.parameter_</c> upon invocation.
///
/// \note
/// \li T should be a type supported by class Value,
/// \li prototype of E::setParameter should be exactly as specified in this
/// example.
template <class E, typename T>
class Setter : public Command {
public:
/// Pointer to method that sets parameter of type T
typedef void (E::*SetterMethod)(const T &);
/// Constructor
Setter(E &entity, SetterMethod setterMethod, const std::string &docString);
protected:
virtual Value doExecute();
private:
SetterMethod setterMethod_;
};
} // namespace command
} // namespace dynamicgraph
#include "dynamic-graph/command-setter.t.cpp"
#endif // DYNAMIC_GRAPH_COMMAND_SETTER_H
//
// Copyright 2010 CNRS
//
// Author: Florent Lamiraux
//
#ifndef DYNAMIC_GRAPH_COMMAND_SETTER_T_CPP
#define DYNAMIC_GRAPH_COMMAND_SETTER_T_CPP
#include "dynamic-graph/command-setter.h"
#include <boost/assign/list_of.hpp>
#include <sstream>
#include "dynamic-graph/linear-algebra.h"
namespace dynamicgraph {
class Entity;
namespace command {
//
// Template specialization: bool
//
template <class E>
class Setter<E, bool> : public Command {
public:
/// Pointer to method that sets parameter of type bool
typedef void (E::*SetterMethod)(const bool &);
/// Constructor
Setter(E &entity, SetterMethod setterMethod, const std::string &docString);
protected:
virtual Value doExecute();
private:
SetterMethod setterMethod_;
}; // Class Setter
template <class E>
Setter<E, bool>::Setter(E &entity, SetterMethod setterMethod,
const std::string &docString)
: Command(entity, boost::assign::list_of(Value::BOOL), docString),
setterMethod_(setterMethod) {}
template <class E>
Value Setter<E, bool>::doExecute() {
const std::vector<Value> &values = getParameterValues();
// Get parameter
bool value = values[0].value();
E &entity = static_cast<E &>(owner());
(entity.*setterMethod_)(value);
return Value();
}
//
// Template specialization: unsigned
//
template <class E>
class Setter<E, unsigned> : public Command {
public:
/// Pointer to method that sets parameter of type unsigned
typedef void (E::*SetterMethod)(const unsigned &);
/// Constructor
Setter(E &entity, SetterMethod setterMethod, const std::string &docString);
protected:
virtual Value doExecute();
private:
SetterMethod setterMethod_;
}; // Class Setter
template <class E>
Setter<E, unsigned>::Setter(E &entity, SetterMethod setterMethod,
const std::string &docString)
: Command(entity, boost::assign::list_of(Value::UNSIGNED), docString),
setterMethod_(setterMethod) {}
template <class E>
Value Setter<E, unsigned>::doExecute() {
const std::vector<Value> &values = getParameterValues();
// Get parameter
unsigned value = values[0].value();
E &entity = static_cast<E &>(owner());
(entity.*setterMethod_)(value);
return Value();
}
//
// Template specialization: int
//
template <class E>
class Setter<E, int> : public Command {
public:
/// Pointer to method that sets parameter of type int
typedef void (E::*SetterMethod)(const int &);
/// Constructor
Setter(E &entity, SetterMethod setterMethod, const std::string &docString);
protected:
virtual Value doExecute();
private:
SetterMethod setterMethod_;
}; // Class Setter
template <class E>
Setter<E, int>::Setter(E &entity, SetterMethod setterMethod,
const std::string &docString)
: Command(entity, boost::assign::list_of(Value::INT), docString),
setterMethod_(setterMethod) {}
template <class E>
Value Setter<E, int>::doExecute() {
const std::vector<Value> &values = getParameterValues();
// Get parameter
int value = values[0].value();
E &entity = static_cast<E &>(owner());
(entity.*setterMethod_)(value);
return Value();
}
//
// Template specialization: float
//
template <class E>
class Setter<E, float> : public Command {
public:
/// Pointer to method that sets parameter of type float
typedef void (E::*SetterMethod)(const float &);
/// Constructor
Setter(E &entity, SetterMethod setterMethod, const std::string &docString);
protected:
virtual Value doExecute();
private:
SetterMethod setterMethod_;
}; // Class Setter
template <class E>
Setter<E, float>::Setter(E &entity, SetterMethod setterMethod,
const std::string &docString)
: Command(entity, boost::assign::list_of(Value::FLOAT), docString),
setterMethod_(setterMethod) {}
template <class E>
Value Setter<E, float>::doExecute() {
const std::vector<Value> &values = getParameterValues();
// Get parameter
float value = values[0].value();
E &entity = static_cast<E &>(owner());
(entity.*setterMethod_)(value);
return Value();
}
//
// Template specialization: double
//
template <class E>
class Setter<E, double> : public Command {
public:
/// Pointer to method that sets parameter of type double
typedef void (E::*SetterMethod)(const double &);
/// Constructor
Setter(E &entity, SetterMethod setterMethod, const std::string &docString);
protected:
virtual Value doExecute();
private:
SetterMethod setterMethod_;
}; // Class Setter
template <class E>
Setter<E, double>::Setter(E &entity, SetterMethod setterMethod,
const std::string &docString)
: Command(entity, boost::assign::list_of(Value::DOUBLE), docString),
setterMethod_(setterMethod) {}
template <class E>
Value Setter<E, double>::doExecute() {
const std::vector<Value> &values = getParameterValues();
// Get parameter
double value = values[0].value();
E &entity = static_cast<E &>(owner());
(entity.*setterMethod_)(value);
return Value();
}
//
// Template specialization: std::string
//
template <class E>
class Setter<E, std::string> : public Command {
public:
/// Pointer to method that sets parameter of type std::string
typedef void (E::*SetterMethod)(const std::string &);
/// Constructor
Setter(E &entity, SetterMethod setterMethod, const std::string &docString);
protected:
virtual Value doExecute();
private:
SetterMethod setterMethod_;
}; // Class Setter
template <class E>
Setter<E, std::string>::Setter(E &entity, SetterMethod setterMethod,
const std::string &docString)
: Command(entity, boost::assign::list_of(Value::STRING), docString),
setterMethod_(setterMethod) {}
template <class E>
Value Setter<E, std::string>::doExecute() {
const std::vector<Value> &values = getParameterValues();
// Get parameter
std::string value = values[0].value();
E &entity = static_cast<E &>(owner());
(entity.*setterMethod_)(value);
return Value();
}
//
// Template specialization: Vector
//
template <class E>
class Setter<E, Vector> : public Command {
public:
/// Pointer to method that sets parameter of type Vector
typedef void (E::*SetterMethod)(const Vector &);
/// Constructor
Setter(E &entity, SetterMethod setterMethod, const std::string &docString);
protected:
virtual Value doExecute();
private:
SetterMethod setterMethod_;
}; // Class Setter
template <class E>
Setter<E, Vector>::Setter(E &entity, SetterMethod setterMethod,
const std::string &docString)
: Command(entity, boost::assign::list_of(Value::VECTOR), docString),
setterMethod_(setterMethod) {}
template <class E>
Value Setter<E, Vector>::doExecute() {
const std::vector<Value> &values = getParameterValues();
// Get parameter
Vector value = values[0].value();
E &entity = static_cast<E &>(owner());
(entity.*setterMethod_)(value);
return Value();
}
//
// Template specialization: Matrix
//
template <class E>
class Setter<E, Matrix> : public Command {
public:
/// Pointer to method that sets parameter of type Matrix
typedef void (E::*SetterMethod)(const Matrix &);
/// Constructor
Setter(E &entity, SetterMethod setterMethod, const std::string &docString);
protected:
virtual Value doExecute();
private:
SetterMethod setterMethod_;
}; // Class Setter
template <class E>
Setter<E, Matrix>::Setter(E &entity, SetterMethod setterMethod,
const std::string &docString)
: Command(entity, boost::assign::list_of(Value::MATRIX), docString),
setterMethod_(setterMethod) {}
template <class E>
Value Setter<E, Matrix>::doExecute() {
const std::vector<Value> &values = getParameterValues();
// Get parameter
Matrix value = values[0].value();
E &entity = static_cast<E &>(owner());
(entity.*setterMethod_)(value);
return Value();
}
} // namespace command
} // namespace dynamicgraph
#endif // DYNAMIC_GRAPH_COMMAND_SETTER_T_CPP
//
// Copyright 2010 CNRS
//
// Author: Florent Lamiraux
//
#ifndef DYNAMIC_GRAPH_COMMAND_H
#define DYNAMIC_GRAPH_COMMAND_H
#include <vector>
#include "dynamic-graph/dynamic-graph-api.h"
#include "dynamic-graph/value.h"
namespace dynamicgraph {
class Entity;
namespace command {
/// \ingroup dgraph
/// Abstract class for entity commands
///
/// This class provide a mean to control entities from external
/// python script.
///
/// A command
/// \li is owned by an entity,
/// \li takes parameters of type Value,
/// \li return an instance of Value when calling Command::execute()
///
/// At construction, the prototype of the command is defined by providing
/// a vector of Value::Type.
///
/// Parameters are set by calling Command::setParameterValues with a
/// vector of Values the types of which should fit the vector specified
/// at construction.
class DYNAMIC_GRAPH_DLLAPI Command {
public:
virtual ~Command();
/// Store the owner entity and a vector of value types
/// \param entity reference to Entity owning this command.
/// \param valueTypes vector specifying the number and types of parameters
/// \param docstring documentation of the command
Command(Entity &entity, const std::vector<Value::Type> &valueTypes,
const std::string &docstring);
/// Return the value type of all parameters
const std::vector<Value::Type> &valueTypes() const;
/// Set parameter values
void setParameterValues(const std::vector<Value> &values);
/// Get parameter values
const std::vector<Value> &getParameterValues() const;
/// Execute the command after checking parameters
Value execute();
/// Get a reference to the Entity owning this command
Entity &owner();
/// Get documentation string
std::string getDocstring() const;
protected:
/// Specific action performed by the command
virtual Value doExecute() = 0;
private:
Entity &owner_;
std::vector<Value::Type> valueTypeVector_;
std::vector<Value> valueVector_;
std::string docstring_;
public:
static const std::vector<Value::Type> EMPTY_ARG;
};
} // namespace command
} // namespace dynamicgraph
#endif // DYNAMIC_GRAPH_COMMAND_H
/*
* Copyright 2010,
* François Bleibel,
* Olivier Stasse,
*
* CNRS/AIST
*
* This file is part of dynamic-graph.
* dynamic-graph is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
* dynamic-graph is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details. You should
* have received a copy of the GNU Lesser General Public License along
* with dynamic-graph. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __CONTIIFSTREAM_HH__
#define __CONTIIFSTREAM_HH__
/* --------------------------------------------------------------------- */
/* --- INCLUDE --------------------------------------------------------- */
/* --------------------------------------------------------------------- */
#include <iostream>
#include <fstream>
#include <sstream>
#ifndef WIN32
#include <unistd.h>
#endif
#include <list>
#include <dynamic-graph/interpreter.h>
#ifndef WIN32
#include <pthread.h>
#endif
/* --------------------------------------------------------------------- */
/* --- API ------------------------------------------------------------- */
/* --------------------------------------------------------------------- */
#if defined (WIN32)
# if defined (contiifstream_EXPORTS)
# define DYNAMICGRAPHCONTIIFSTREAM_EXPORT __declspec(dllexport)
# else
# define DYNAMICGRAPHCONTIIFSTREAM_EXPORT __declspec(dllimport)
# endif
#else
# define DYNAMICGRAPHCONTIIFSTREAM_EXPORT
#endif
namespace dynamicgraph {
/* --------------------------------------------------------------------- */
/* --- CLASS ----------------------------------------------------------- */
/* --------------------------------------------------------------------- */
class DYNAMICGRAPHCONTIIFSTREAM_EXPORT Contiifstream
{
protected:
std::string filename;
unsigned int cursor;
static const unsigned int BUFFER_SIZE = 256;
char buffer[BUFFER_SIZE];
std::list< std::string > reader;
bool first;
public: /* --- Constructor --- */
Contiifstream( const std::string& n="" );
~Contiifstream( void );
void open( const std::string& n ) { filename=n; cursor=0; }
public: /* --- READ FILE --- */
bool loop( void );
public: /* --- READ LIST --- */
inline bool ready( void ) { return 0<reader.size();}
std::string next( void ) ;
};
} // namespace dynamicgraph
#endif /* #ifndef __CONTIIFSTREAM_HH__ */
/*
* Copyright 2010,
* François Bleibel,
* Olivier Stasse,
*
* CNRS/AIST
*
* This file is part of dynamic-graph.
* dynamic-graph is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
* dynamic-graph is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details. You should
* have received a copy of the GNU Lesser General Public License along
* with dynamic-graph. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* Macro de trace et de debugage
*
* - TRACAGE: TRACE et ERROR_TRACE fonctionnent comme des printf
* avec retour chariot en fin de fonction.
* CERROR et CTRACE fonctionnent comme les flux de sortie
* C++ cout et cerr.
* - DEBUGAGE: DEBUG_TRACE(niv, et DERROR_TRACE(niv, fonctionnent
* comme des printf, n'imprimant que si le niveau de trace 'niv' est
* superieur au mode de debugage VP_DEBUG_MODE.
* CDEBUG(niv) fonctionne comme le flux de sortie C++ cout.
* DEBUG_ENABLE(niv) vaut 1 ssi le niveau de tracage 'niv'
* est superieur au mode de debugage DEBUG_MODE. Il vaut 0 sinon.
* - PROG DEFENSIVE: DEFENSIF(a) vaut a ssi le mode defensif est active,
* et vaut 0 sinon.
*
* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
#ifndef __DEBUG_HH
#define __DEBUG_HH
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <sstream>
#include <stdarg.h>
#include <dynamic-graph/dynamic-graph-api.h>
// -*- mode: c++ -*-
// Copyright 2010, François Bleibel, Thomas Moulard, Olivier Stasse,
// JRL, CNRS/AIST.
//
#ifndef DYNAMIC_GRAPH_DEBUG_HH
#define DYNAMIC_GRAPH_DEBUG_HH
#include <dynamic-graph/dynamic-graph-api.h>
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
#include <cstdarg>
#include <cstdio>
#include <dynamic-graph/fwd.hh>
#include <fstream>
#include <sstream>
#ifndef VP_DEBUG_MODE
#define VP_DEBUG_MODE 0
#endif
#endif //! VP_DEBUG_MODE
#ifndef VP_TEMPLATE_DEBUG_MODE
#define VP_TEMPLATE_DEBUG_MODE 0
#endif
#endif //! VP_TEMPLATE_DEBUG_MODE
#define DG_COMMON_TRACES do { \
va_list arg; \
va_start(arg,format); \
vsnprintf( charbuffer,SIZE,format,arg ); \
va_end(arg); \
outputbuffer << tmpbuffer.str() << charbuffer <<std::endl; \
} while(0)
#define DG_COMMON_TRACES \
do { \
va_list arg; \
va_start(arg, format); \
vsnprintf(charbuffer, SIZE, format, arg); \
va_end(arg); \
outputbuffer << tmpbuffer.str() << charbuffer << std::endl; \
} while (0)
namespace dynamicgraph {
class DYNAMIC_GRAPH_DLLAPI DebugTrace
{
/// \ingroup debug
///
/// \brief Logging class.
///
/// This class should never be used directly, please use the
/// debugging macro instead.
class DYNAMIC_GRAPH_DLLAPI DebugTrace {
public:
static const int SIZE = 512;
static const int SIZE = 512;
std::stringstream tmpbuffer;
std::ostream &outputbuffer;
char charbuffer[SIZE + 1];
int traceLevel;
int traceLevelTemplate;
DebugTrace(std::ostream &os) : outputbuffer(os) {}
inline void trace(const int level, const char *format, ...) {
if (level <= traceLevel) DG_COMMON_TRACES;
tmpbuffer.str("");
}
inline void trace(const char *format, ...) {
DG_COMMON_TRACES;
tmpbuffer.str("");
}
inline void trace(const int level = -1) {
if (level <= traceLevel) {
outputbuffer << tmpbuffer.str();
tmpbuffer.str("");
}
}
inline void traceTemplate(const int level, const char *format, ...) {
if (level <= traceLevelTemplate) DG_COMMON_TRACES;
tmpbuffer.str("");
}
inline void traceTemplate(const char *format, ...) {
DG_COMMON_TRACES;
tmpbuffer.str("");
}
inline DebugTrace &pre(const std::ostream &) { return *this; }
inline DebugTrace &pre(const std::ostream &, int level) {
traceLevel = level;
return *this;
}
static const char *DEBUG_FILENAME_DEFAULT;
static void openFile(const char *filename = DEBUG_FILENAME_DEFAULT);
static void closeFile(const char *filename = DEBUG_FILENAME_DEFAULT);
};
std::stringstream tmpbuffer;
std::ostream& outputbuffer;
char charbuffer[SIZE+1];
int traceLevel;
int traceLevelTemplate;
DYNAMIC_GRAPH_DLLAPI extern DebugTrace dgDEBUGFLOW;
DYNAMIC_GRAPH_DLLAPI extern DebugTrace dgERRORFLOW;
} // end of namespace dynamicgraph
DebugTrace( std::ostream& os ): outputbuffer(os) {}
#ifdef VP_DEBUG
inline void trace( const int level,const char* format,...)
{ if( level<=traceLevel ) DG_COMMON_TRACES; tmpbuffer.str(""); }
inline void trace( const char* format,...){ DG_COMMON_TRACES; tmpbuffer.str(""); }
inline void trace( const int level=-1 )
{ if( level<=traceLevel ) outputbuffer << tmpbuffer.str(); tmpbuffer.str(""); }
#define dgPREDEBUG __FILE__ << ": " << __FUNCTION__ << "(#" << __LINE__ << ") :"
#define dgPREERROR \
"\t!! " << __FILE__ << ": " << __FUNCTION__ << "(#" << __LINE__ << ") :"
#define dgDEBUG(level) \
if ((level > VP_DEBUG_MODE) || (!dgDEBUGFLOW.outputbuffer.good())) \
; \
else \
dgDEBUGFLOW.outputbuffer << dgPREDEBUG
#define dgDEBUGMUTE(level) \
if ((level > VP_DEBUG_MODE) || (!dgDEBUGFLOW.outputbuffer.good())) \
; \
else \
dgDEBUGFLOW.outputbuffer
#define dgERROR \
if (!dgDEBUGFLOW.outputbuffer.good()) \
; \
else \
dgERRORFLOW.outputbuffer << dgPREERROR
#define dgDEBUGF \
if (!dgDEBUGFLOW.outputbuffer.good()) \
; \
else \
dgDEBUGFLOW.pre(dgDEBUGFLOW.tmpbuffer << dgPREDEBUG, VP_DEBUG_MODE).trace
#define dgERRORF \
if (!dgDEBUGFLOW.outputbuffer.good()) \
; \
else \
dgERRORFLOW.pre(dgERRORFLOW.tmpbuffer << dgPREERROR).trace
inline void traceTemplate( const int level,const char* format,...)
{ if( level<=traceLevelTemplate ) DG_COMMON_TRACES; tmpbuffer.str(""); }
inline void traceTemplate( const char* format,...)
{ DG_COMMON_TRACES; tmpbuffer.str(""); }
// TEMPLATE
#define dgTDEBUG(level) \
if ((level > VP_TEMPLATE_DEBUG_MODE) || (!dgDEBUGFLOW.outputbuffer.good())) \
; \
else \
dgDEBUGFLOW.outputbuffer << dgPREDEBUG
inline DebugTrace& pre( const std::ostream& dummy ) { return *this; }
inline DebugTrace& pre( const std::ostream& dummy,int level )
{ traceLevel = level; return *this; }
/* inline DebugTrace& preTemplate( const std::ostream& dummy,int level ) */
/* { traceLevelTemplate = level; return *this; } */
#define dgTDEBUGF \
if (!dgDEBUGFLOW.outputbuffer.good()) \
; \
else \
dgDEBUGFLOW \
.pre(dgDEBUGFLOW.tmpbuffer << dgPREDEBUG, VP_TEMPLATE_DEBUG_MODE) \
.trace
inline bool dgDEBUG_ENABLE(const int &level) { return level <= VP_DEBUG_MODE; }
static const char * DEBUG_FILENAME_DEFAULT;
static void openFile( const char * filename = DEBUG_FILENAME_DEFAULT );
static void closeFile( const char * filename = DEBUG_FILENAME_DEFAULT );
inline bool dgTDEBUG_ENABLE(const int &level) {
return level <= VP_TEMPLATE_DEBUG_MODE;
}
};
#else // VP_DEBUG
DYNAMIC_GRAPH_DLLAPI extern DebugTrace dgDEBUGFLOW;
DYNAMIC_GRAPH_DLLAPI extern DebugTrace dgERRORFLOW;
#define dgPREERROR \
"\t!! " << __FILE__ << ": " << __FUNCTION__ << "(#" << __LINE__ << ") :"
} // namespace dynamicgraph
#define dgDEBUG(level) \
if (1) \
; \
else \
::dynamicgraph::__null_stream()
#define dgDEBUGMUTE \
(level) if (1); \
else ::dynamicgraph::__null_stream()
#define dgERROR dgERRORFLOW.outputbuffer << dgPREERROR
inline void dgDEBUGF(const int, const char *, ...) { return; }
inline void dgDEBUGF(const char *, ...) { return; }
inline void dgERRORF(const int, const char *, ...) { return; }
inline void dgERRORF(const char *, ...) { return; }
namespace dynamicgraph {
inline std::ostream &__null_stream() {
// This function should never be called. With -O3,
// it should not appear in the generated binary.
static std::ostream os(NULL);
return os;
}
} // namespace dynamicgraph
#ifdef VP_DEBUG
#define dgPREDEBUG __FILE__ << ": " <<__FUNCTION__ \
<< "(#" << __LINE__ << ") :"
#define dgPREERROR "\t!! "<<__FILE__ << ": " <<__FUNCTION__ \
<< "(#" << __LINE__ << ") :"
# define dgDEBUG(level) if( (level>VP_DEBUG_MODE)||(!dgDEBUGFLOW.outputbuffer.good()) ) ;\
else dgDEBUGFLOW.outputbuffer << dgPREDEBUG
# define dgDEBUGMUTE(level) if( (level>VP_DEBUG_MODE)||(!dgDEBUGFLOW.outputbuffer.good()) ) ;\
else dgDEBUGFLOW.outputbuffer
# define dgERROR if(!dgDEBUGFLOW.outputbuffer.good()); else dgERRORFLOW.outputbuffer << dgPREERROR
# define dgDEBUGF if(!dgDEBUGFLOW.outputbuffer.good()); else dgDEBUGFLOW.pre(dgDEBUGFLOW.tmpbuffer<<dgPREDEBUG,VP_DEBUG_MODE).trace
# define dgERRORF if(!dgDEBUGFLOW.outputbuffer.good()); else dgERRORFLOW.pre(dgERRORFLOW.tmpbuffer<<dgPREERROR).trace
// TEMPLATE
# define dgTDEBUG(level) if( (level>VP_TEMPLATE_DEBUG_MODE)||(!dgDEBUGFLOW.outputbuffer.good()) ) ;\
else dgDEBUGFLOW.outputbuffer << dgPREDEBUG
# define dgTDEBUGF if(!dgDEBUGFLOW.outputbuffer.good()); else dgDEBUGFLOW.pre(dgDEBUGFLOW.tmpbuffer<<dgPREDEBUG,VP_TEMPLATE_DEBUG_MODE).trace
inline bool dgDEBUG_ENABLE( const int & level ) { return level<=VP_DEBUG_MODE; }
inline bool dgTDEBUG_ENABLE( const int & level ) { return level<=VP_TEMPLATE_DEBUG_MODE; }
/* -------------------------------------------------------------------------- */
#else // #ifdef VP_DEBUG
#define dgPREERROR "\t!! "<<__FILE__ << ": " <<__FUNCTION__ \
<< "(#" << __LINE__ << ") :"
# define dgDEBUG(level) if( 1 ) ; else std::cout
# define dgDEBUGMUTE(level) if( 1 ) ; else std::cout
# define dgERROR dgERRORFLOW.outputbuffer << dgPREERROR
inline void dgDEBUGF( const int level,const char* format,...) { return; }
inline void dgDEBUGF( const char* format,...) { return; }
inline void dgERRORF( const int level,const char* format,...) { return; }
inline void dgERRORF( const char* format,...) { return; }
// TEMPLATE
# define dgTDEBUG(level) if( 1 ) ; else std::cout
inline void dgTDEBUGF( const int level,const char* format,...) { return; }
inline void dgTDEBUGF( const char* format,...) { return; }
#define dgTDEBUG(level) \
if (1) \
; \
else \
::dynamicgraph::__null_stream()
inline void dgTDEBUGF(const int, const char *, ...) { return; }
inline void dgTDEBUGF(const char *, ...) { return; }
#define dgDEBUG_ENABLE(level) false
#define dgTDEBUG_ENABLE(level) false
#endif // #ifdef VP_DEBUG
/* -------------------------------------------------------------------------- */
#endif //! VP_DEBUG
#define dgDEBUGIN(level) dgDEBUG(level) << "# In {" << std::endl
#define dgDEBUGOUT(level) dgDEBUG(level) << "# Out }" << std::endl
#define dgDEBUGINOUT(level) dgDEBUG(level) << "# In/Out { }" << std::endl
#define dgTDEBUGIN(level) dgTDEBUG(level) << "# In {" << std::endl
#define dgTDEBUGOUT(level) dgTDEBUG(level) << "# Out }" << std::endl
#define dgTDEBUGINOUT(level) dgTDEBUG(level) << "# In/Out { }" << std::endl
#define dgTDEBUGOUT(level) dgTDEBUG(level) << "# Out }" << std::endl
#endif /* #ifdef __VS_DEBUG_HH */
#define dgTDEBUGINOUT(level) dgTDEBUG(level) << "# In/Out { }" << std::endl
/*
* Local variables:
* c-basic-offset: 4
* End:
*/
#endif //! DYNAMIC_GRAPH_DEBUG_HH
/*
* Copyright 2010,
* François Bleibel,
* Olivier Stasse,
*
* CNRS/AIST
*
* This file is part of dynamic-graph.
* dynamic-graph is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
* dynamic-graph is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details. You should
* have received a copy of the GNU Lesser General Public License along
* with dynamic-graph. If not, see <http://www.gnu.org/licenses/>.
*/
// -*- mode: c++ -*-
// Copyright 2010, François Bleibel, Thomas Moulard, Olivier Stasse,
// JRL, CNRS/AIST.
//
#ifndef DYNAMICGRAPH_API_H
# define DYNAMICGRAPH_API_H
# include <dynamic-graph/config.hh>
#endif //! DYNAMICGRAPH_API_H
#ifndef DYNAMIC_GRAPH_API_H
#define DYNAMIC_GRAPH_API_H
#include <dynamic-graph/config.hh>
#endif //! DYNAMIC_GRAPH_API_H
//
// Copyright 2016 CNRS
//
// Author: Rohan Budhiraja
//
#ifndef DYNAMIC_GRAPH_EIGEN_IO_H
#define DYNAMIC_GRAPH_EIGEN_IO_H
#include <dynamic-graph/exception-signal.h>
#include <dynamic-graph/linear-algebra.h>
#include <Eigen/Geometry>
#include <boost/format.hpp>
#include <boost/numeric/conversion/cast.hpp>
using dynamicgraph::ExceptionSignal;
// TODO: Eigen 3.3 onwards has a global Eigen::Index definition.
// If Eigen version is updated, use Eigen::Index instead of this macro.
/* \brief Eigen Vector input from istream
*
* Input Vector format: [N](val1,val2,val3,...,valN)
* e.g. [5](1,23,32.2,12.12,32)
*/
namespace Eigen {
typedef EIGEN_DEFAULT_DENSE_INDEX_TYPE eigen_index;
inline std::istringstream &operator>>(std::istringstream &iss,
dynamicgraph::Vector &inst) {
unsigned int _size;
double _dbl_val;
char _ch;
boost::format fmt(
"Failed to enter %s as vector."
" Reenter as [N](val1,val2,val3,...,valN)");
fmt % iss.str();
if (iss >> _ch && _ch != '[') {
throw ExceptionSignal(ExceptionSignal::GENERIC, fmt.str());
} else {
if (iss >> _size && !iss.fail()) {
inst.resize(_size);
} else
throw ExceptionSignal(ExceptionSignal::GENERIC, fmt.str());
if (iss >> _ch && _ch != ']')
throw ExceptionSignal(ExceptionSignal::GENERIC, fmt.str());
else {
if (iss >> _ch && _ch != '(')
throw ExceptionSignal(ExceptionSignal::GENERIC, fmt.str());
else {
for (unsigned int i = 0; i < _size; i++) {
iss >> _dbl_val;
if (iss.peek() == ',' || iss.peek() == ' ') iss.ignore();
inst(i) = _dbl_val;
}
if (iss >> _ch && _ch != ')')
throw ExceptionSignal(ExceptionSignal::GENERIC, fmt.str());
}
}
}
return iss;
}
/* \brief Eigen Matrix input from istream
*
* Matrix format: [M,N]((val11,val12,val13,...,val1N),...,
* (valM1,valM2,...,valMN))
* e.g. [2,5]((1 23 32.2 12.12 32),(2 32 23 92.01 19.2))
*/
template <typename Derived>
inline std::istringstream &operator>>(std::istringstream &iss,
DenseBase<Derived> &inst) {
unsigned int _colsize;
unsigned int _rowsize;
double _dbl_val;
char _ch;
boost::format fmt(
"Failed to enter %s as matrix. Reenter as "
"((val11,val12,val13,...,val1N),"
"...,(valM1,valM2,...,valMN))");
MatrixXd _tmp_matrix;
fmt % iss.str();
if (iss >> _ch && _ch != '[') {
throw ExceptionSignal(ExceptionSignal::GENERIC, fmt.str());
} else {
iss >> _rowsize;
if (iss.peek() == ',' || iss.peek() == ' ') iss.ignore();
iss >> _colsize;
if (iss.fail())
throw ExceptionSignal(ExceptionSignal::GENERIC, fmt.str());
else {
_tmp_matrix.resize(_rowsize, _colsize);
if (iss >> _ch && _ch != ']')
throw ExceptionSignal(ExceptionSignal::GENERIC, fmt.str());
else {
if (iss >> _ch && _ch != '(')
throw ExceptionSignal(ExceptionSignal::GENERIC, fmt.str());
else {
for (unsigned int j = 0; j < _rowsize; j++) {
if (iss >> _ch && _ch != '(')
throw ExceptionSignal(ExceptionSignal::GENERIC, fmt.str());
for (unsigned int i = 0; i < _colsize; i++) {
iss >> _dbl_val;
if (iss.peek() == ',' || iss.peek() == ' ') iss.ignore();
_tmp_matrix(j, i) = _dbl_val;
}
if (iss >> _ch && _ch != ')')
throw ExceptionSignal(ExceptionSignal::GENERIC, fmt.str());
if (iss.peek() == ',' || iss.peek() == ' ') iss.ignore();
}
if (iss >> _ch && _ch != ')')
throw ExceptionSignal(ExceptionSignal::GENERIC, fmt.str());
}
}
}
}
inst = _tmp_matrix;
return iss;
}
inline std::istringstream &operator>>(std::istringstream &iss,
Transform<double, 3, Affine> &inst) {
MatrixXd M;
iss >> M;
inst.matrix() = M;
return iss;
}
/* \brief Eigen Homogeneous Matrix output
*
* Matrix format: [M,N]((val11,val12,val13,...,val1N),...,
* (valM1,valM2,...,valMN))
* e.g. [2,5]((1 23 32.2 12.12 32),(2 32 23 92.01 19.2))
*/
inline std::ostream &operator<<(std::ostream &os,
Transform<double, 3, Affine> MH) {
IOFormat boostFmt(StreamPrecision, DontAlignCols, ",", ",", "(", ")", "(",
")");
os << "[4,4]" << MH.matrix().format(boostFmt);
return os;
}
inline std::ostream &operator<<(std::ostream &os, AngleAxisd quat) {
VectorXd v(4);
v(0) = quat.angle();
v.tail<3>() = quat.axis();
os << v;
return os;
}
inline std::istringstream &operator>>(std::istringstream &iss,
AngleAxisd &inst) {
VectorXd v(4);
iss >> v;
inst.angle() = v(0);
inst.axis() = v.tail<3>();
return iss;
}
} // namespace Eigen
#endif // DYNAMIC_GRAPH_EIGEN_IO_H
/*
* Copyright 2011, Nicolas Mansard, LAAS-CNRS
*
*/
#ifndef __sot_core_entity_helper_H__
#define __sot_core_entity_helper_H__
namespace dynamicgraph {
template <typename Ent>
struct EntityHelper {
typedef Ent EntityClassName;
// static const std::string CLASS_NAME; TO BE ADDED IN DG DIRECTLY
};
} // namespace dynamicgraph
#endif // __sot_core_entity_helper_H__
/*
* Copyright 2010,
* François Bleibel,
* Olivier Stasse,
*
* CNRS/AIST
*
* This file is part of dynamic-graph.
* dynamic-graph is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
* dynamic-graph is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details. You should
* have received a copy of the GNU Lesser General Public License along
* with dynamic-graph. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __ENTITY_HH__
#define __ENTITY_HH__
/* --------------------------------------------------------------------- */
/* --- INCLUDE --------------------------------------------------------- */
/* --------------------------------------------------------------------- */
/* DYNAMIC-GRAPH */
#include <dynamic-graph/signal-base.h>
// -*- mode: c++ -*-
// Copyright 2010, François Bleibel, Thomas Moulard, Olivier Stasse,
// JRL, CNRS/AIST.
//
#ifndef DYNAMIC_GRAPH_ENTITY_H
#define DYNAMIC_GRAPH_ENTITY_H
#include <dynamic-graph/dynamic-graph-api.h>
#include <dynamic-graph/exception-factory.h>
#include <dynamic-graph/logger.h>
#include <dynamic-graph/signal-array.h>
#include <dynamic-graph/dynamic-graph-api.h>
#include <dynamic-graph/signal-base.h>
/* --- STD --- */
#include <string>
#include <boost/noncopyable.hpp>
#include <dynamic-graph/fwd.hh>
#include <iosfwd>
#include <map>
#include <sstream>
#include <string>
/* --- BOOST --- */
#include <boost/noncopyable.hpp>
/// \brief Helper macro for entity declaration.
///
/// This macro should be called in the declaration of all entities.
/// Example:
/// <code>
/// class A : public dynamicgraph::entity
/// {
/// DYNAMIC_GRAPH_ENTITY_DECL();
///
/// public:
// // your class here
/// };
/// </code>
///
/// Caution: you *MUST* call DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN in the
/// associated source file to ensure that the attributes generated by
/// this macro are correctly initialized.
#define DYNAMIC_GRAPH_ENTITY_DECL() \
public: \
virtual const std::string &getClassName() const { return CLASS_NAME; } \
static const std::string CLASS_NAME
/* NAMESPACE */
namespace dynamicgraph {
/* --------------------------------------------------------------------- */
/* --- CLASS ----------------------------------------------------------- */
/* --------------------------------------------------------------------- */
/*! \ingroup dgraph
\brief This class represents an entity, i.e. a generic
computational unit that provides input and output signals.
These signals link the entities together to form a complete computation graph.
To declare a new entity, please see the DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN macro
in g_factory.h.
A command-line interface provided by the entity can be used by a sot shell to
call methods from entities and display the result of their execution.
Classes that derive from Entity can customize the command-line by overriding commandLine().
*/
class DYNAMIC_GRAPH_DLLAPI Entity
: private boost::noncopyable
{
/// \ingroup dgraph
///
/// \brief This class represents an entity, i.e. a generic
/// computational unit that provides input and output signals.
///
/// These signals link the entities together to form a complete
/// computation graph. To declare a new entity, please see the
/// DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN macro in factory.h.
class DYNAMIC_GRAPH_DLLAPI Entity : private boost::noncopyable {
public:
typedef std::map<std::string, SignalBase<int> *> SignalMap;
typedef std::map<const std::string, command::Command *> CommandMap_t;
explicit Entity(const std::string &name);
virtual ~Entity();
const std::string &getName() const { return name; }
virtual const std::string &getClassName() const {
static std::string ret("Entity");
return ret;
}
/** \brief Returns the Entity documentation
\return The documentation is provided as std::string object.
*/
virtual std::string getDocString() const;
/** \brief Test if a signal of name signame is present.
\return True if the signal is present, False otherwise
*/
bool hasSignal(const std::string &signame) const;
/** \brief Provides a reference to the signal named signalName.
\param signalName: Name of the signal
\return A reference to the signal with a temporal dependency.
*/
SignalBase<int> &getSignal(const std::string &signalName);
/** \brief Provides a const reference to the signal named signalName.
\param signalName: Name of the signal
\return A const reference to the signal with a temporal dependency.
*/
const SignalBase<int> &getSignal(const std::string &signalName) const;
/** \brief Display the list of signals of this entity in output stream os.
\param os: the output stream where to display the list of signals.
\returns The output stream given in parameter.
*/
std::ostream &displaySignalList(std::ostream &os) const;
/** \brief This method is used to write down in os the edges of the graph
by calling the signals writeGraph method.
\param os: The output stream where to write the informations.
\return os: The output stream.
*/
virtual std::ostream &writeGraph(std::ostream &os) const;
/** \brief This method is used write in the output stream os the
signals names and the commands of the entity.
\param os: The output stream where to write the list of objects
related to the entity.
*/
virtual std::ostream &writeCompletionList(std::ostream &os) const;
/** \brief Display information on the entity inside the output stream os.
*/
virtual void display(std::ostream &os) const;
virtual SignalBase<int> *test() { return 0; }
virtual void test2(SignalBase<int> *) { return; }
const std::string &getCommandList() const;
/** \brief Provides the std::map where all the commands are registered
\returns A map of pointers towards Command objects
*/
CommandMap_t getNewStyleCommandMap();
/** \brief Provides the pointer towards the Command object cmdName.
\param cmdName: Name of the command
*/
command::Command *getNewStyleCommand(const std::string &cmdName);
/** \brief Provides a map of all the signals.
\returns A copy of the map with all the pointers towards
the entity signals.
*/
SignalMap getSignalMap() const;
/// \name Logger related methods
/// \{
Logger &logger() { return logger_; };
Logger const &logger() const { return logger_; };
/// \brief Send messages \c msg with level \c t.
/// Add string file and line to message.
void sendMsg(const std::string &msg, MsgType t = MSG_TYPE_INFO,
const std::string &lineId = "");
/// \brief Specify the verbosity level of the logger.
void setLoggerVerbosityLevel(LoggerVerbosity lv) { logger_.setVerbosity(lv); }
/// \brief Get the logger's verbosity level.
LoggerVerbosity getLoggerVerbosityLevel() { return logger_.getVerbosity(); }
/// \brief Set the time sample.
bool setTimeSample(double t) { return logger_.setTimeSample(t); }
/// \brief Get the time sample.
double getTimeSample() { return logger_.getTimeSample(); }
/// \brief Set the period of the stream period
bool setStreamPrintPeriod(double t) {
return logger_.setStreamPrintPeriod(t);
}
/// \brief Get the period of the stream period
double getStreamPrintPeriod() { return logger_.getStreamPrintPeriod(); }
/// \}
protected:
std::string name;
void addCommand(const std::string &name, command::Command *command);
void entityRegistration( void );
void entityDeregistration( void );
void entityRegistration();
void entityDeregistration();
public:
Entity( const std::string& name );
virtual ~Entity( void );
static const std::string CLASS_NAME;
const std::string& getName( void ) const { return name; }
virtual const std::string& getClassName( void ) const { return CLASS_NAME; }
void signalRegistration(const SignalArray<int> &signals);
void signalDeregistration(const std::string &name);
protected: /* --- SIGNALS --- */
typedef std::map< std::string,SignalBase<int>* > SignalMap;
std::string name;
SignalMap signalMap;
void signalRegistration( const SignalArray<int>& signals );
void signalDeregistration( const std::string& name );
public:
SignalBase<int>& getSignal( const std::string & signalName );
const SignalBase<int>& getSignal( const std::string & signalName ) const;
std::ostream& displaySignalList( std::ostream& os ) const;
virtual std::ostream& writeGraph( std::ostream& os ) const;
virtual std::ostream& writeCompletionList( std::ostream& os ) const;
public: /* --- DISPLAY --- */
virtual void display( std::ostream& os ) const;
public: /* --- PARAMS --- */
virtual void commandLine( const std::string& cmdLine,std::istringstream& cmdArgs,
std::ostream& os );
virtual SignalBase<int>* test(void) { return 0; }
virtual void test2( SignalBase<int>* ptr ) { return ; }
virtual const std::string& getCommandList( void ) const;
CommandMap_t commandMap;
Logger logger_;
};
DYNAMIC_GRAPH_DLLAPI std::ostream& operator<< (std::ostream& os, const dynamicgraph::Entity& ent );
} // namespace dynamicgraph
#endif /* #ifndef __ENTITY_HH__ */
DYNAMIC_GRAPH_DLLAPI std::ostream &operator<<(std::ostream &os,
const dynamicgraph::Entity &ent);
} // end of namespace dynamicgraph
#endif //! DYNAMIC_GRAPH_ENTITY_H
/*
* Copyright 2010,
* François Bleibel,
* Olivier Stasse,
*
* CNRS/AIST
*
* This file is part of dynamic-graph.
* dynamic-graph is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
* dynamic-graph is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details. You should
* have received a copy of the GNU Lesser General Public License along
* with dynamic-graph. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __ABSTRACT_EXCEPTION_H
#define __ABSTRACT_EXCEPTION_H
/* --------------------------------------------------------------------- */
/* --- INCLUDE --------------------------------------------------------- */
/* --------------------------------------------------------------------- */
/* Classes standards. */
#include <iostream> /* Classe ostream. */
#include <string> /* Classe string. */
// -*- mode: c++ -*-
// Copyright 2010, François Bleibel, Thomas Moulard, Olivier Stasse,
// JRL, CNRS/AIST.
//
#ifndef DYNAMIC_GRAPH_EXCEPTION_ABSTRACT_H
#define DYNAMIC_GRAPH_EXCEPTION_ABSTRACT_H
#include <dynamic-graph/dynamic-graph-api.h>
#include <dynamic-graph/fwd.hh>
#include <string>
// Uncomment this macros to have lines parameter on the throw display
// #define DYNAMIC-GRAPH_EXCEPTION_PASSING_PARAM
/* --------------------------------------------------------------------- */
/* --- CLASS ----------------------------------------------------------- */
/* --------------------------------------------------------------------- */
namespace dynamicgraph {
#define DG_RETHROW \
(const ::dynamicgraph::ExceptionAbstract &err) { throw err; }
/* \class ExceptionAbstract
*/
class DYNAMIC_GRAPH_DLLAPI ExceptionAbstract : public std::exception
{
#ifdef DYNAMICGRAPH_EXCEPTION_PASSING_PARAM
#define DG_THROW \
throw ::dynamicgraph::ExceptionAbstract::Param(__LINE__, __FUNCTION__, \
__FILE__) +
#else
#define DG_THROW throw
#endif // DYNAMICGRAPH_EXCEPTION_PASSING_PARAM
namespace dynamicgraph {
/// \ingroup error
///
/// \brief Abstract root class for all dynamic-graph exceptions.
class DYNAMIC_GRAPH_DLLAPI ExceptionAbstract : public std::exception {
public:
enum ExceptionEnum
{
ABSTRACT = 0
,SIGNAL = 100
,FACTORY = 200
,TRACES = 300
,TOOLS = 700
};
/// \ingroup error
///
/// \brief Class owned by exceptions to store error locations.
class Param {
public:
static const int BUFFER_SIZE = 80;
Param(const int &_line, const char *_function, const char *_file);
Param()
: functionPTR(),
function(),
line(),
filePTR(),
file(),
pointersSet(false),
set(false) {}
Param &initCopy(const Param &p);
const char *functionPTR;
char function[BUFFER_SIZE];
int line;
const char *filePTR;
char file[BUFFER_SIZE];
bool pointersSet;
bool set;
};
/// \brief Categories error code.
///
/// Each value matches categories used by a subclass of
/// ExceptionAbstract.
///
/// This is the programmer responsibility to make sure there is
/// enough room between two categories error code.
enum ExceptionEnum {
ABSTRACT = 0,
SIGNAL = 100,
FACTORY = 200,
TRACES = 300,
TOOLS = 700
};
static const std::string EXCEPTION_NAME;
virtual const std::string& getExceptionName( void ) const { return EXCEPTION_NAME; }
protected:
/** Error code.
* \sa ErrorCodeEnum */
int code;
/** Error message (can be empty). */
std::string message;
private:
explicit ExceptionAbstract(const int &code, const std::string &msg = "");
virtual ~ExceptionAbstract() throw() {}
/** forbid the empty constructor (private). */
ExceptionAbstract( void );
public:
virtual const std::string &getExceptionName() const { return EXCEPTION_NAME; }
ExceptionAbstract( const int& code, const std::string & msg = "" );
virtual ~ExceptionAbstract( void ) throw() {}
/// \brief Access to the error code.
int getCode() const;
/** Access to the error code. */
int getCode (void);
/// \brief Reference access to the error message (can be empty).
const std::string &getStringMessage() const;
/** Reference access to the error message (can be empty). */
const std::string& getStringMessage (void) const;
/// \brief Access to the pointer on the array of \e char related
/// to the error string.
///
/// Cannot be \e NULL.
const char *getMessage() const;
/** Access to the pointer on the array of \e char related to the error string.
* Cannot be \e NULL.
*/
const char *getMessage (void);
virtual const char* what() const throw()
{
virtual const char *what() const throw() {
return getStringMessage().c_str();
}
/** Print the error structure. */
DYNAMIC_GRAPH_DLLAPI friend std::ostream & operator << (std::ostream & os,
const ExceptionAbstract & err);
#ifdef DYNAMICGRAPH_EXCEPTION_PASSING_PARAM
public:
class Param
{
public:
static const int BUFFER_SIZE = 80;
const char * functionPTR;
char function[ BUFFER_SIZE ];
int line;
const char * filePTR;
char file[ BUFFER_SIZE ];
bool pointersSet,set;
public:
Param( const int& _line, const char * _function, const char * _file );
Param( void ) : pointersSet(false),set(false) {}
Param& initCopy( const Param& p );
};
/// \brief Print the error structure.
DYNAMIC_GRAPH_DLLAPI friend std::ostream &operator<<(
std::ostream &os, const ExceptionAbstract &err);
protected:
mutable Param p;
template<class Exc>
friend const Exc& operator+ ( const ExceptionAbstract::Param& p, const Exc& e )
{ e.p.initCopy(p); return e; }
template<class Exc>
friend Exc& operator+ ( const ExceptionAbstract::Param& p, Exc& e )
{ e.p.initCopy(p); return e; }
#endif //#ifdef DYNAMICGRAPH_EXCEPTION_PASSING_PARAM
};
} // namespace dynamicgraph
/// \brief Error code.
/// \sa ErrorCodeEnum
int code;
#define DG_RETHROW ( const ExceptionAbstract& err ) { throw err; }
/// \brief Error message (can be empty).
std::string message;
#ifdef DYNAMICGRAPH_EXCEPTION_PASSING_PARAM
/// \brief Optional mutable attribute to store exception location.
///
/// Only present if DYNAMICGRAPH_EXCEPTION_PASSING_PARAM
/// preprocessor symbol exists.
mutable Param p;
template <class Exc>
friend const Exc &operator+(const ExceptionAbstract::Param &p, const Exc &e) {
e.p.initCopy(p);
return e;
}
#ifdef DYNAMICGRAPH_EXCEPTION_PASSING_PARAM
# define DG_THROW throw ExceptionAbstract::Param(__LINE__,__FUNCTION__,__FILE__) +
#else //#ifdef DYNAMICGRAPH_EXCEPTION_PASSING_PARAM
# define DG_THROW throw
#endif //#ifdef DYNAMICGRAPH_EXCEPTION_PASSING_PARAM
template <class Exc>
friend Exc &operator+(const ExceptionAbstract::Param &p, Exc &e) {
e.p.initCopy(p);
return e;
}
#endif // DYNAMICGRAPH_EXCEPTION_PASSING_PARAM
#endif /* #ifndef __ABSTRACT_EXCEPTION_H */
private:
/// \brief Forbid the empty constructor (private).
ExceptionAbstract();
};
} // end of namespace dynamicgraph
/*
* Local variables:
* c-basic-offset: 2
* End:
*/
#endif //! DYNAMIC_GRAPH_EXCEPTION_ABSTRACT_H
/*
* Copyright 2010,
* François Bleibel,
* Olivier Stasse,
*
* CNRS/AIST
*
* This file is part of dynamic-graph.
* dynamic-graph is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
* dynamic-graph is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details. You should
* have received a copy of the GNU Lesser General Public License along
* with dynamic-graph. If not, see <http://www.gnu.org/licenses/>.
*/
// -*- mode: c++ -*-
// Copyright 2010, François Bleibel, Thomas Moulard, Olivier Stasse,
// JRL, CNRS/AIST.
//
#ifndef __EXCEPTION_FACTORY_H
#define __EXCEPTION_FACTORY_H
/* --------------------------------------------------------------------- */
/* --- INCLUDE --------------------------------------------------------- */
/* --------------------------------------------------------------------- */
#include <dynamic-graph/exception-abstract.h>
#ifndef DYNAMIC_GRAPH_EXCEPTION_FACTORY_H
#define DYNAMIC_GRAPH_EXCEPTION_FACTORY_H
#include <dynamic-graph/dynamic-graph-api.h>
#include <dynamic-graph/exception-abstract.h>
/* --------------------------------------------------------------------- */
/* --- CLASS ----------------------------------------------------------- */
/* --------------------------------------------------------------------- */
#include <dynamic-graph/fwd.hh>
#include <string>
namespace dynamicgraph {
/* \class sotExceptionFactory
*/
class DYNAMIC_GRAPH_DLLAPI ExceptionFactory
:public ExceptionAbstract
{
public:
enum ErrorCodeEnum
{
GENERIC = ExceptionAbstract::FACTORY
,UNREFERED_OBJECT
,UNREFERED_SIGNAL
,UNREFERED_FUNCTION
,DYNAMIC_LOADING
,SIGNAL_CONFLICT
,FUNCTION_CONFLICT
,OBJECT_CONFLICT
,SYNTAX_ERROR // j' aime bien FATAL_ERROR aussi faut que je la case qq part...
,READ_FILE
};
/// \ingroup error
///
/// \brief Generic error class.
class DYNAMIC_GRAPH_DLLAPI ExceptionFactory : public ExceptionAbstract {
public:
enum ErrorCodeEnum {
GENERIC = ExceptionAbstract::FACTORY,
UNREFERED_OBJECT,
UNREFERED_SIGNAL,
UNREFERED_FUNCTION,
DYNAMIC_LOADING,
SIGNAL_CONFLICT,
FUNCTION_CONFLICT,
OBJECT_CONFLICT,
SYNTAX_ERROR,
READ_FILE
};
static const std::string EXCEPTION_NAME;
virtual const std::string& getExceptionName( void )const{ return ExceptionFactory::EXCEPTION_NAME; }
ExceptionFactory ( const ExceptionFactory::ErrorCodeEnum& errcode,
const std::string & msg = "" );
ExceptionFactory ( const ExceptionFactory::ErrorCodeEnum& errcode,
const std::string & msg,const char* format, ... );
virtual ~ExceptionFactory( void ) throw() {}
};
explicit ExceptionFactory(const ExceptionFactory::ErrorCodeEnum &errcode,
const std::string &msg = "");
} // namespace dynamicgraph
ExceptionFactory(const ExceptionFactory::ErrorCodeEnum &errcode,
const std::string &msg, const char *format, ...);
virtual ~ExceptionFactory() throw() {}
#endif /* #ifndef __EXCEPTION_FACTORY_H */
virtual const std::string &getExceptionName() const {
return ExceptionFactory::EXCEPTION_NAME;
}
};
} // end of namespace dynamicgraph
/*
* Local variables:
* c-basic-offset: 2
* End:
*/
#endif //! DYNAMIC_GRAPH_EXCEPTION_FACTORY_H
/*
* Copyright 2010,
* François Bleibel,
* Olivier Stasse,
*
* CNRS/AIST
*
* This file is part of dynamic-graph.
* dynamic-graph is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
* dynamic-graph is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details. You should
* have received a copy of the GNU Lesser General Public License along
* with dynamic-graph. If not, see <http://www.gnu.org/licenses/>.
*/
// -*- mode: c++ -*-
// Copyright 2010, François Bleibel, Thomas Moulard, Olivier Stasse,
// JRL, CNRS/AIST.
//
#ifndef __SIGNAL_EXCEPTION_H
#define __SIGNAL_EXCEPTION_H
#ifndef DYNAMIC_GRAPH_EXCEPTION_SIGNAL_H
#define DYNAMIC_GRAPH_EXCEPTION_SIGNAL_H
/* --------------------------------------------------------------------- */
/* --- INCLUDE --------------------------------------------------------- */
/* --------------------------------------------------------------------- */
#include <dynamic-graph/exception-abstract.h>
#include <dynamic-graph/dynamic-graph-api.h>
#include <dynamic-graph/exception-abstract.h>
/* --------------------------------------------------------------------- */
/* --- CLASS ----------------------------------------------------------- */
/* --------------------------------------------------------------------- */
#include <dynamic-graph/fwd.hh>
namespace dynamicgraph {
/* \class sotExceptionSignal
*/
class DYNAMIC_GRAPH_DLLAPI ExceptionSignal
:public ExceptionAbstract
{
/// \ingroup error
///
/// \brief Exceptions raised when an error related to signals
/// happen.
class DYNAMIC_GRAPH_DLLAPI ExceptionSignal : public ExceptionAbstract {
public:
enum ErrorCodeEnum
{
GENERIC = ExceptionAbstract::SIGNAL
,READWRITE_LOCK
,COPY_NOT_INITIALIZED
,NOT_INITIALIZED
,PLUG_IMPOSSIBLE
,SET_IMPOSSIBLE
,BAD_CAST
};
enum ErrorCodeEnum {
GENERIC = ExceptionAbstract::SIGNAL,
READWRITE_LOCK,
COPY_NOT_INITIALIZED,
NOT_INITIALIZED,
PLUG_IMPOSSIBLE,
SET_IMPOSSIBLE,
BAD_CAST
};
static const std::string EXCEPTION_NAME;
virtual const std::string& getExceptionName( void ) const { return EXCEPTION_NAME; }
public:
ExceptionSignal ( const ExceptionSignal::ErrorCodeEnum& errcode,
const std::string & msg = "" );
ExceptionSignal( const ExceptionSignal::ErrorCodeEnum& errcode,
const std::string & msg,const char* format, ... );
virtual ~ExceptionSignal( void ) throw() {}
explicit ExceptionSignal(const ExceptionSignal::ErrorCodeEnum &errcode,
const std::string &msg = "");
ExceptionSignal(const ExceptionSignal::ErrorCodeEnum &errcode,
const std::string &msg, const char *format, ...);
virtual ~ExceptionSignal() throw() {}
virtual const std::string &getExceptionName() const { return EXCEPTION_NAME; }
};
} // namespace dynamicgraph
#endif /* #ifndef __SIGNAL_EXCEPTION_H */
} // end of namespace dynamicgraph
/*
* Local variables:
* c-basic-offset: 2
* End:
*/
#endif //! DYNAMIC_GRAPH_EXCEPTION_SIGNAL_H