1 |
|
|
// -*- mode: c++ -*- |
2 |
|
|
// Copyright 2010, François Bleibel, Thomas Moulard, Olivier Stasse, |
3 |
|
|
// JRL, CNRS/AIST. |
4 |
|
|
// |
5 |
|
|
|
6 |
|
|
#ifndef DYNAMIC_GRAPH_TRACER_REAL_TIME_H |
7 |
|
|
#define DYNAMIC_GRAPH_TRACER_REAL_TIME_H |
8 |
|
|
#include <dynamic-graph/tracer.h> |
9 |
|
|
|
10 |
|
|
#include <dynamic-graph/config-tracer-real-time.hh> |
11 |
|
|
#include <dynamic-graph/fwd.hh> |
12 |
|
|
#include <sstream> |
13 |
|
|
|
14 |
|
|
namespace dynamicgraph { |
15 |
|
|
/// \ingroup plugin |
16 |
|
|
/// |
17 |
|
|
/// \brief Stream for the tracer real-time. |
18 |
|
|
class DG_TRACERREALTIME_DLLAPI OutStringStream : public std::ostringstream { |
19 |
|
|
public: |
20 |
|
|
char *buffer; |
21 |
|
|
std::streamsize index; |
22 |
|
|
std::streamsize bufferSize; |
23 |
|
|
bool full; |
24 |
|
|
std::string givenname; |
25 |
|
|
|
26 |
|
|
public: |
27 |
|
|
OutStringStream(); |
28 |
|
|
~OutStringStream(); |
29 |
|
|
|
30 |
|
|
void resize(const std::streamsize &size); |
31 |
|
|
bool addData(const char *data, const std::streamoff &size); |
32 |
|
|
void dump(std::ostream &os); |
33 |
|
|
void empty(); |
34 |
|
|
}; |
35 |
|
|
|
36 |
|
|
/// \ingroup plugin |
37 |
|
|
/// |
38 |
|
|
/// \brief Main class of the tracer real-time plug-in. |
39 |
|
|
class DG_TRACERREALTIME_DLLAPI TracerRealTime : public Tracer { |
40 |
|
|
DYNAMIC_GRAPH_ENTITY_DECL(); |
41 |
|
|
|
42 |
|
|
public: |
43 |
|
|
TracerRealTime(const std::string &n); |
44 |
|
|
virtual ~TracerRealTime() {} |
45 |
|
|
|
46 |
|
|
virtual void closeFiles(); |
47 |
|
|
virtual void trace(); |
48 |
|
|
|
49 |
|
|
void display(std::ostream &os) const; |
50 |
|
|
DG_TRACERREALTIME_DLLAPI friend std::ostream &operator<<( |
51 |
|
|
std::ostream &os, const TracerRealTime &t); |
52 |
|
|
|
53 |
|
|
void emptyBuffers(); |
54 |
|
|
|
55 |
|
1 |
void setBufferSize(const int &SIZE) { bufferSize = SIZE; } |
56 |
|
|
|
57 |
|
|
const int &getBufferSize() { return bufferSize; } |
58 |
|
|
|
59 |
|
|
protected: |
60 |
|
|
virtual void openFile(const SignalBase<int> &sig, |
61 |
|
|
const std::string &filename); |
62 |
|
|
|
63 |
|
|
virtual void recordSignal(std::ostream &os, const SignalBase<int> &sig); |
64 |
|
|
|
65 |
|
|
typedef std::list<std::ofstream *> HardFileList; |
66 |
|
|
static const int BUFFER_SIZE_DEFAULT = 1048576; // 1Mo |
67 |
|
|
|
68 |
|
|
int bufferSize; |
69 |
|
|
HardFileList hardFiles; |
70 |
|
|
}; |
71 |
|
|
} // end of namespace dynamicgraph |
72 |
|
|
|
73 |
|
|
#endif //! DYNAMIC_GRAPH_TRACER_REAL_TIME_H |