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 894 additions and 803 deletions
......@@ -5,14 +5,14 @@
#ifndef DYNAMIC_GRAPH_POOL_H
#define DYNAMIC_GRAPH_POOL_H
#include <map>
#include <string>
#include <sstream>
#include <dynamic-graph/fwd.hh>
#include <dynamic-graph/dynamic-graph-api.h>
#include <dynamic-graph/exception-factory.h>
#include <dynamic-graph/signal-base.h>
#include <dynamic-graph/dynamic-graph-api.h>
#include <dynamic-graph/fwd.hh>
#include <map>
#include <sstream>
#include <string>
namespace dynamicgraph {
/*! @ingroup dgraph
......@@ -36,10 +36,10 @@ class DYNAMIC_GRAPH_DLLAPI PoolStorage {
@{
*/
/*! \brief Sorted set of entities with unique key (name). */
typedef std::map<std::string, Entity*> Entities;
typedef std::map<std::string, Entity *> Entities;
/// \brief Get unique instance of the class.
static PoolStorage* getInstance();
static PoolStorage *getInstance();
/// \brief Destroy the unique instance of the class
static void destroy();
......@@ -56,47 +56,47 @@ class DYNAMIC_GRAPH_DLLAPI PoolStorage {
\par[in] entname: The name of the entity,
\par[in] ent: Pointer towards the entity.
*/
void registerEntity(const std::string& entname, Entity* ent);
void registerEntity(const std::string &entname, Entity *ent);
/*! \brief Unregister an entity.
\par[in] entname: The name of the entity,
*/
void deregisterEntity(const std::string& entname);
void deregisterEntity(const std::string &entname);
/*! \brief Unregister an entity.
\par[in] entity: iterator in the map,
*/
void deregisterEntity(const Entities::iterator& entity);
void deregisterEntity(const Entities::iterator &entity);
/*! \brief Get an entity.
\par[in] entname: The name of the entity,
\return Pointer towards the entity.
*/
Entity& getEntity(const std::string& name);
Entity &getEntity(const std::string &name);
/// Const access to entity map
const Entities& getEntityMap() const;
const Entities &getEntityMap() const;
/*! \brief Test if the entity exists. */
bool existEntity(const std::string& name);
bool existEntity(const std::string &name);
/*! \brief Test if the entity exists. If it does, return a pointer on it. */
bool existEntity(const std::string& name, Entity*& ptr);
bool existEntity(const std::string &name, Entity *&ptr);
/*! \brief Disallocate an entity.
\par[in] entname: The name of the entity,
*/
void clearPlugin(const std::string& name);
void clearPlugin(const std::string &name);
/*! @} */
///
/// \brief Get a signal by name
///
/// \param sigpath stream containing a string of the form "entity.signal"
SignalBase<int>& getSignal(std::istringstream& sigpath);
SignalBase<int> &getSignal(std::istringstream &sigpath);
/*! \brief This method write a graph description on the file named
FileName. */
void writeGraph(const std::string& aFileName);
void writeCompletionList(std::ostream& os);
void writeGraph(const std::string &aFileName);
void writeCompletionList(std::ostream &os);
protected:
/*! \name Fields of the class to manage the three entities.
......@@ -108,10 +108,10 @@ class DYNAMIC_GRAPH_DLLAPI PoolStorage {
private:
PoolStorage() {}
static PoolStorage* instance_;
static PoolStorage *instance_;
};
inline PoolStorage& g_pool() { return *PoolStorage::getInstance(); }
inline PoolStorage &g_pool() { return *PoolStorage::getInstance(); }
} // end of namespace dynamicgraph.
......
......@@ -4,14 +4,14 @@
*/
#ifndef DYNAMIC_GRAPH_PROCESS_LIST_H_
#define DYNAMIC_GRAPH_PROCESS_LIST_H
#define DYNAMIC_GRAPH_PROCESS_LIST_H_
#include <dynamic-graph/dynamic-graph-api.h>
#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>
#include <boost/archive/text_oarchive.hpp>
#include <boost/serialization/vector.hpp>
#include <dynamic-graph/fwd.hh>
#include <dynamic-graph/dynamic-graph-api.h>
namespace dynamicgraph {
namespace CPU {
......@@ -22,14 +22,15 @@ class DYNAMIC_GRAPH_DLLAPI ProcessList {
ProcessList();
};
/// \class This class gather information on a specific CPU.
/// This class gather information on a specific CPU.
///
class DYNAMIC_GRAPH_DLLAPI CPUData {
public:
CPUData();
int cpu_id_;
inline unsigned long long int computePeriod(unsigned long long int &a, unsigned long long int &b) {
inline unsigned long long int computePeriod(unsigned long long int &a,
unsigned long long int &b) {
return (a > b) ? a - b : 0;
}
......@@ -122,7 +123,7 @@ class DYNAMIC_GRAPH_DLLAPI CPUData {
}
};
/// \class This class gathers information on a computer.
/// This class gathers information on a computer.
/// This includes a list of CPU
class DYNAMIC_GRAPH_DLLAPI System {
private:
......
// -*- mode: c++ -*-
// Copyright 2018, Joseph Mirabel LAAS-CNRS
//
#ifndef DYNAMIC_GRAPH_LOGGER_REAL_TIME_DEF_H
#define DYNAMIC_GRAPH_LOGGER_REAL_TIME_DEF_H
#include <boost/shared_ptr.hpp>
#include <boost/thread/mutex.hpp>
#include <dynamic-graph/config.hh>
#include <sstream>
#include <vector>
namespace dynamicgraph {
/// \ingroup debug
///
/// \brief Stream for the real-time logger.
///
/// You should inherit from this class in order to redirect the logs where you
/// want.
/// \sa LoggerIOStream
class LoggerStream {
public:
virtual void write(const char *c) = 0;
};
/// Write to an ostream object.
///
/// The easieast is to use the macro dgADD_OSTREAM_TO_RTLOG(ostr) where
/// `ostr` can be `std::cout` or an std::ofstream...
class LoggerIOStream : public LoggerStream {
public:
LoggerIOStream(std::ostream &os) : os_(os) {}
virtual ~LoggerIOStream() {}
virtual void write(const char *c) { os_ << c; }
private:
std::ostream &os_;
};
typedef boost::shared_ptr<LoggerStream> LoggerStreamPtr_t;
class RealTimeLogger;
/// \cond DEVEL
/// \brief write entries to intenal buffer.
///
/// The entry starts when an instance is created and ends when is is deleted.
/// This class is only used by RealTimeLogger.
class RTLoggerStream {
public:
inline RTLoggerStream(RealTimeLogger *logger, std::ostream &os)
: ok_(logger != NULL), logger_(logger), os_(os) {}
template <typename T>
inline RTLoggerStream &operator<<(T t) {
if (ok_) os_ << t;
return *this;
}
inline RTLoggerStream &operator<<(std::ostream &(*pf)(std::ostream &)) {
if (ok_) os_ << pf;
return *this;
}
inline ~RTLoggerStream();
inline bool isNull() { return !ok_; }
private:
const bool ok_;
RealTimeLogger *logger_;
std::ostream &os_;
};
/// \endcond DEVEL
/// \ingroup debug
///
/// \brief Main class of the real-time logger.
///
/// It is intended to be used like this:
/// \code
/// #define ENABLE_RT_LOG
/// #include <dynamic-graph/real-time-logger.h>
///
/// // Somewhere in the main function of your executable
/// int main (int argc, char** argv) {
/// dgADD_OSTREAM_TO_RTLOG (std::cout);
/// }
///
/// // Somewhere in your library
/// dgRTLOG() << "your message. Prefer to use \n than std::endl."
/// \endcode
///
/// \note Thread safety. This class expects to have:
/// - only one reader: the one who take the log entries and write them
/// somewhere.
/// - one writer at a time. Writing to the logs is **never** a blocking
/// operation. If the resource is busy, the log entry is discarded.
class DYNAMIC_GRAPH_DLLAPI RealTimeLogger {
public:
static RealTimeLogger &instance();
static void destroy();
/// \todo add an argument to preallocate the internal string
/// to a given size.
RealTimeLogger(const std::size_t &bufferSize);
inline void clearOutputStreams() { outputs_.clear(); }
inline void addOutputStream(const LoggerStreamPtr_t &os) {
outputs_.push_back(os);
}
/// Write next message to output.
/// It does nothing if the buffer is empty.
/// \return true if it wrote something
bool spinOnce();
/// Return an object onto which a real-time thread can write.
/// The message is considered finished when the object is destroyed.
RTLoggerStream front();
/// Return an empty stream object.
RTLoggerStream emptyStream() { return RTLoggerStream(NULL, oss_); }
inline void frontReady() {
backIdx_ = (backIdx_ + 1) % buffer_.size();
wmutex.unlock();
}
inline bool empty() const { return frontIdx_ == backIdx_; }
inline bool full() const {
return ((backIdx_ + 1) % buffer_.size()) == frontIdx_;
}
inline std::size_t size() const {
if (frontIdx_ <= backIdx_)
return backIdx_ - frontIdx_;
else
return backIdx_ + buffer_.size() - frontIdx_;
}
inline std::size_t getBufferSize() { return buffer_.size(); }
~RealTimeLogger();
private:
struct Data {
std::stringbuf buf;
};
std::vector<LoggerStreamPtr_t> outputs_;
std::vector<Data *> buffer_;
/// Index of the next value to be read.
std::size_t frontIdx_;
/// Index of the slot where to write next value
/// (does not contain valid data).
std::size_t backIdx_;
std::ostream oss_;
/// The writer mutex.
boost::mutex wmutex;
std::size_t nbDiscarded_;
struct thread;
static RealTimeLogger *instance_;
static thread *thread_;
};
RTLoggerStream::~RTLoggerStream() {
if (ok_) {
os_ << std::ends;
logger_->frontReady();
}
}
} // end of namespace dynamicgraph
#endif //! DYNAMIC_GRAPH_LOGGER_REAL_TIME_DEF_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.
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.