AGX Dynamics 2.38.0.2
Loading...
Searching...
No Matches
LogListener.h
Go to the documentation of this file.
1/*
2Copyright 2007-2024. Algoryx Simulation AB.
3
4All AGX source code, intellectual property, documentation, sample code,
5tutorials, scene files and technical white papers, are copyrighted, proprietary
6and confidential material of Algoryx Simulation AB. You may not download, read,
7store, distribute, publish, copy or otherwise disseminate, use or expose this
8material unless having a written signed agreement with Algoryx Simulation AB, or having been
9advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10valid commercial license from Algoryx Simulation AB.
11
12Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13from using this software, unless otherwise stated in written agreements with
14Algoryx Simulation AB.
15*/
16
17#ifndef AGXSDK_LOGLISTENER_H
18#define AGXSDK_LOGLISTENER_H
19
20#include <agxSDK/agxSDK.h>
22#include <string>
23#include <sstream>
24
25namespace agxSDK
26{
27
30 {
31 public:
32
38
46 LogListener(const std::string& fileName = "",
47 bool newFilePerTimeStep = false,
48 const std::string& valueSeparator = "\t");
49
51 virtual void pre(const agx::TimeStamp& /*time*/);
53 virtual void post( const agx::TimeStamp& /*time*/ );
54
55 inline void setFileName( const std::string& fileName );
56 inline void setNewFilePerTimeStep( bool newFilePerTimeStep );
57 inline void setValueSeparator( const std::string& valueSeparator );
58 inline void setPrecision( int precision );
59 inline void setNumberFormat( NumberFormat format );
60
61 inline std::string getFileName() const;
62 inline bool getNewFilePerTimeStep() const;
63 inline std::string getValueSeparator() const;
64 inline int getPrecision() const;
65 inline NumberFormat getNumberFormat() const;
66
67 protected:
69 virtual void obtainHeader( std::stringstream& /*header*/ ) {}
71 virtual void collectData ( std::stringstream& /*data*/, const agx::TimeStamp& /*time*/ ) {}
72
73 private:
74 void writeToFile( const std::string& text, const agx::TimeStamp& time, bool append );
75
76
77 protected:
78 std::string m_fileName;
82 std::string m_separator;
84 };
85
87
88
89 inline void LogListener::setFileName( const std::string& fileName )
90 {
91 m_fileName = fileName;
92 }
93
94 inline void LogListener::setNewFilePerTimeStep( bool newFilePerTimeStep )
95 {
96 m_newFilePerTimeStep = newFilePerTimeStep;
97 }
98
99 inline void LogListener::setValueSeparator( const std::string& valueSeparator )
100 {
101 m_separator = valueSeparator;
102 }
103
104 inline void LogListener::setPrecision( int precision )
105 {
106 m_precision = precision;
107 }
108
110 {
111 m_format = format;
112 }
113
114 inline int LogListener::getPrecision() const
115 {
116 return m_precision;
117 }
118
120 {
122 }
123
124 inline std::string LogListener::getValueSeparator() const
125 {
126 return m_separator;
127 }
128
129 inline std::string LogListener::getFileName() const
130 {
131 return m_fileName;
132 }
133
138
139}
140
141#endif /* AGXSDK_LOGLISTENER_H */
#define AGXPHYSICS_EXPORT
Abstract class for logging properties per time step to a file/standard out.
Definition LogListener.h:30
virtual void post(const agx::TimeStamp &)
inherited from StepEventListener
void setValueSeparator(const std::string &valueSeparator)
Definition LogListener.h:99
int getPrecision() const
bool getNewFilePerTimeStep() const
NumberFormat m_format
Definition LogListener.h:83
std::string getValueSeparator() const
virtual void pre(const agx::TimeStamp &)
inherited from StepEventListener
void setPrecision(int precision)
void setNumberFormat(NumberFormat format)
LogListener(const std::string &fileName="", bool newFilePerTimeStep=false, const std::string &valueSeparator="\t")
LogListener constructor.
NumberFormat getNumberFormat() const
void setNewFilePerTimeStep(bool newFilePerTimeStep)
Definition LogListener.h:94
std::string getFileName() const
void setFileName(const std::string &fileName)
Definition LogListener.h:89
virtual void collectData(std::stringstream &, const agx::TimeStamp &)
Implement this function when inheriting.
Definition LogListener.h:71
virtual void obtainHeader(std::stringstream &)
Implement this function when inheriting.
Definition LogListener.h:69
std::string m_separator
Definition LogListener.h:82
std::string m_fileName
Definition LogListener.h:78
Derive from this class to implement a listener for simulation step events.
Smart pointer for handling referenced counted objects.
Definition ref_ptr.h:30
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
Definition Constraint.h:31
agx::ref_ptr< LogListener > LogListenerRef
Definition LogListener.h:86
agx::Real TimeStamp
Definition TimeStamp.h:26