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 1399 additions and 1761 deletions
......@@ -3,17 +3,6 @@
//
// Author: Nicolas Mansard
//
// 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 __dg_command_direct_setter_h__
#define __dg_command_direct_setter_h__
......@@ -26,50 +15,47 @@
*
*/
#include "dynamic-graph/command.h"
#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__
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__
......@@ -3,17 +3,6 @@
//
// Author: Florent Lamiraux
//
// 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 DYNAMIC_GRAPH_COMMAND_GETTER_H
#define DYNAMIC_GRAPH_COMMAND_GETTER_H
......@@ -21,55 +10,53 @@
#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
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
#endif // DYNAMIC_GRAPH_COMMAND_GETTER_H
......@@ -3,43 +3,31 @@
//
// Author: Florent Lamiraux
//
// 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 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 {
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>
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
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
#endif // DYNAMIC_GRAPH_COMMAND_GETTER_T_CPP
......@@ -3,17 +3,6 @@
//
// Author: Florent Lamiraux
//
// 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 DYNAMIC_GRAPH_COMMAND_SETTER_H
#define DYNAMIC_GRAPH_COMMAND_SETTER_H
......@@ -21,55 +10,53 @@
#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
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
#endif // DYNAMIC_GRAPH_COMMAND_SETTER_H
......@@ -3,77 +3,71 @@
//
// Author: Florent Lamiraux
//
// 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 DYNAMIC_GRAPH_COMMAND_H
#define DYNAMIC_GRAPH_COMMAND_H
#include <vector>
#include "dynamic-graph/value.h"
#include "dynamic-graph/dynamic-graph-api.h"
#include "dynamic-graph/value.h"
namespace dynamicgraph {
class Entity;
namespace command {
/// 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
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
#endif // DYNAMIC_GRAPH_COMMAND_H
// -*- mode: c++ -*-
// Copyright 2010, François Bleibel, Thomas Moulard, 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/>.
#ifndef DYNAMIC_GRAPH_CONTIIFSTREAM_H
# define DYNAMIC_GRAPH_CONTIIFSTREAM_H
# include <fstream>
# include <list>
# include <sstream>
# ifndef WIN32
# include <unistd.h>
# include <pthread.h>
# endif //! WIN32
# include <dynamic-graph/fwd.hh>
# include <dynamic-graph/interpreter.h>
# include <dynamic-graph/config-contiifstream.hh>
namespace dynamicgraph
{
/// \ingroup debug
///
/// \brief TODO
///
class DG_CONTIIFSTREAM_DLLAPI Contiifstream
{
public:
explicit Contiifstream (const std::string& n = "");
~Contiifstream ();
inline void open (const std::string& n)
{
filename = n;
cursor = 0;
}
bool loop ();
inline bool ready ()
{
return 0 < reader.size ();
}
std::string next ();
protected:
std::string filename;
std::streamoff cursor;
static const unsigned int BUFFER_SIZE = 256;
char buffer[BUFFER_SIZE];
std::list< std::string > reader;
bool first;
};
} // end of namespace dynamicgraph.
#endif //! DYNAMIC_GRAPH_CONTIIFSTREAM_H
This diff is collapsed.
......@@ -2,20 +2,8 @@
// Copyright 2010, François Bleibel, Thomas Moulard, 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/>.
#ifndef DYNAMIC_GRAPH_API_H
# define DYNAMIC_GRAPH_API_H
# include <dynamic-graph/config.hh>
#endif //! DYNAMIC_GRAPH_API_H
#define DYNAMIC_GRAPH_API_H
#include <dynamic-graph/config.hh>
#endif //! DYNAMIC_GRAPH_API_H
This diff is collapsed.
/*
* Copyright 2011, Nicolas Mansard, LAAS-CNRS
*
* This file is part of sot-core.
* sot-core 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.
* sot-core 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 sot-core. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __sot_core_entity_helper_H__
#define __sot_core_entity_helper_H__
namespace dynamicgraph {
namespace dynamicgraph
{
template <typename Ent>
struct EntityHelper {
typedef Ent EntityClassName;
// static const std::string CLASS_NAME; TO BE ADDED IN DG DIRECTLY
};
template< typename Ent >
struct EntityHelper
{
typedef Ent EntityClassName;
//static const std::string CLASS_NAME; TO BE ADDED IN DG DIRECTLY
};
} // namespace dynamicgraph
} // namespace dynamicgraph
#endif // __sot_core_entity_helper_H__
#endif // __sot_core_entity_helper_H__
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.