Skip to content

Commit e8dc5a2

Browse files
Rationalize usage of integers
- Except at a few places, int have been replaced by dynamic_graph::size_type, also known as Eigen::Matrix::Index. - unsigned int have been replaced by std::size_t.
1 parent f4e2fde commit e8dc5a2

File tree

107 files changed

+444
-426
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+444
-426
lines changed

include/sot/core/abstract-sot-external-interface.hh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
#include <map>
1313
#include <sot/core/api.hh>
14+
#include <sot/core/fwd.hh>
1415
#include <string>
1516
#include <vector>
1617

@@ -61,7 +62,7 @@ class SOT_CORE_EXPORT AbstractSotExternalInterface {
6162
virtual void setSecondOrderIntegration(void) = 0;
6263
virtual void setNoIntegration(void) = 0;
6364
// Set the number of joints that are controlled
64-
virtual void setControlSize(const int &) = 0;
65+
virtual void setControlSize(const size_type &) = 0;
6566
};
6667
} // namespace sot
6768
} // namespace dynamicgraph

include/sot/core/admittance-control-op-point.hh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ class ADMITTANCECONTROLOPPOINT_EXPORT AdmittanceControlOpPoint
108108

109109
protected:
110110
/// Dimension of the force signals and of the output
111-
int m_n;
111+
size_type m_n;
112112
/// True if the entity has been successfully initialized
113113
bool m_initSucceeded;
114114
/// Internal state

include/sot/core/causal-filter.hh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
/* --------------------------------------------------------------------- */
2020
/* --- INCLUDE --------------------------------------------------------- */
2121
/* --------------------------------------------------------------------- */
22-
#include <Eigen/Core>
22+
#include <sot/core/fwd.hh>
2323

2424
/** \addtogroup Filters
2525
\section subsec_causalfilter CausalFilter
@@ -54,7 +54,7 @@ class CausalFilter {
5454
5555
xSize is
5656
*/
57-
CausalFilter(const double &timestep, const int &xSize,
57+
CausalFilter(const double &timestep, const size_type &xSize,
5858
const Eigen::VectorXd &filter_numerator,
5959
const Eigen::VectorXd &filter_denominator);
6060

@@ -68,7 +68,7 @@ class CausalFilter {
6868
/// sampling timestep of the input signal
6969
double m_dt;
7070
/// Size
71-
int m_x_size;
71+
size_type m_x_size;
7272
/// Size of the numerator \f$m\f$
7373
Eigen::VectorXd::Index m_filter_order_m;
7474
/// Size of the denominator \f$n\f$
@@ -80,8 +80,8 @@ class CausalFilter {
8080
Eigen::VectorXd m_filter_denominator;
8181
bool m_first_sample;
8282
///
83-
int m_pt_numerator;
84-
int m_pt_denominator;
83+
size_type m_pt_numerator;
84+
size_type m_pt_denominator;
8585
Eigen::MatrixXd m_input_buffer;
8686
Eigen::MatrixXd m_output_buffer;
8787
}; // class CausalFilter

include/sot/core/clamp-workspace.hh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class SOTCLAMPWORKSPACE_EXPORT ClampWorkspace : public dynamicgraph::Entity {
8989
double dm_max_yaw;
9090
double theta_min;
9191
double theta_max;
92-
int mode;
92+
size_type mode;
9393

9494
enum { FRAME_POINT, FRAME_REF } frame;
9595

include/sot/core/contiifstream.hh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class SOT_CORE_EXPORT Contiifstream {
3636
protected:
3737
std::string filename;
3838
std::streamoff cursor;
39-
static const unsigned int BUFFER_SIZE = 256;
39+
static const std::size_t BUFFER_SIZE = 256;
4040
char buffer[BUFFER_SIZE];
4141
std::list<std::string> reader;
4242
bool first;

include/sot/core/control-gr.hh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class ControlGR_EXPORT ControlGR : public Entity {
7272
SignalTimeDependent<dynamicgraph::Vector, sigtime_t> controlSOUT;
7373

7474
protected:
75-
double &setsize(int dimension);
75+
double &setsize(size_type dimension);
7676
dynamicgraph::Vector &computeControl(dynamicgraph::Vector &tau, sigtime_t t);
7777
};
7878

include/sot/core/debug.hh

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <sstream>
1616

1717
#include "sot/core/api.hh"
18+
#include "sot/core/fwd.hh"
1819

1920
#ifndef VP_DEBUG_MODE
2021
#define VP_DEBUG_MODE 0
@@ -37,17 +38,17 @@ namespace dynamicgraph {
3738
namespace sot {
3839
class SOT_CORE_EXPORT DebugTrace {
3940
public:
40-
static const int SIZE = 512;
41+
static const size_type SIZE = 512;
4142

4243
std::stringstream tmpbuffer;
4344
std::ostream &outputbuffer;
4445
char charbuffer[SIZE + 1];
45-
int traceLevel;
46-
int traceLevelTemplate;
46+
size_type traceLevel;
47+
size_type traceLevelTemplate;
4748

4849
DebugTrace(std::ostream &os) : outputbuffer(os) {}
4950

50-
inline void trace(const int level, const char *format, ...) {
51+
inline void trace(const size_type level, const char *format, ...) {
5152
if (level <= traceLevel) SOT_COMMON_TRACES;
5253
tmpbuffer.str("");
5354
}
@@ -57,12 +58,12 @@ class SOT_CORE_EXPORT DebugTrace {
5758
tmpbuffer.str("");
5859
}
5960

60-
inline void trace(const int level = -1) {
61+
inline void trace(const size_type level = -1) {
6162
if (level <= traceLevel) outputbuffer << tmpbuffer.str();
6263
tmpbuffer.str("");
6364
}
6465

65-
inline void traceTemplate(const int level, const char *format, ...) {
66+
inline void traceTemplate(const size_type level, const char *format, ...) {
6667
if (level <= traceLevelTemplate) SOT_COMMON_TRACES;
6768
tmpbuffer.str("");
6869
}
@@ -74,7 +75,7 @@ class SOT_CORE_EXPORT DebugTrace {
7475

7576
inline DebugTrace &pre(const std::ostream &) { return *this; }
7677

77-
inline DebugTrace &pre(const std::ostream &, int level) {
78+
inline DebugTrace &pre(const std::ostream &, size_type level) {
7879
traceLevel = level;
7980
return *this;
8081
}
@@ -150,9 +151,11 @@ SOT_CORE_EXPORT extern DebugTrace sotERRORFLOW;
150151

151152
namespace dynamicgraph {
152153
namespace sot {
153-
inline bool sotDEBUG_ENABLE(const int &level) { return level <= VP_DEBUG_MODE; }
154+
inline bool sotDEBUG_ENABLE(const size_type &level) {
155+
return level <= VP_DEBUG_MODE;
156+
}
154157

155-
inline bool sotTDEBUG_ENABLE(const int &level) {
158+
inline bool sotTDEBUG_ENABLE(const size_type &level) {
156159
return level <= VP_TEMPLATE_DEBUG_MODE;
157160
}
158161
} // namespace sot
@@ -176,9 +179,9 @@ inline bool sotTDEBUG_ENABLE(const int &level) {
176179

177180
namespace dynamicgraph {
178181
namespace sot {
179-
inline void sotDEBUGF(const int, const char *, ...) {}
182+
inline void sotDEBUGF(const size_type, const char *, ...) {}
180183
inline void sotDEBUGF(const char *, ...) {}
181-
inline void sotERRORF(const int, const char *, ...) {}
184+
inline void sotERRORF(const size_type, const char *, ...) {}
182185
inline void sotERRORF(const char *, ...) {}
183186
inline std::ostream &__null_stream() {
184187
// This function should never be called. With -O3,
@@ -198,7 +201,7 @@ inline std::ostream &__null_stream() {
198201

199202
namespace dynamicgraph {
200203
namespace sot {
201-
inline void sotTDEBUGF(const int, const char *, ...) {}
204+
inline void sotTDEBUGF(const size_type, const char *, ...) {}
202205
inline void sotTDEBUGF(const char *, ...) {}
203206
} // namespace sot
204207
} // namespace dynamicgraph

include/sot/core/device.hh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,13 @@ class SOT_CORE_EXPORT Device : public Entity {
8080
/* --- DESTRUCTION --- */
8181
virtual ~Device();
8282

83-
virtual void setStateSize(const unsigned int &size);
83+
virtual void setStateSize(const size_type &size);
8484
// Set number of joints that are controlled by the device.
85-
void setControlSize(const int &size);
85+
void setControlSize(const size_type &size);
8686
// Get the number of joints that are controlled by the device.
87-
int getControlSize() const;
87+
size_type getControlSize() const;
8888
virtual void setState(const dynamicgraph::Vector &st);
89-
void setVelocitySize(const unsigned int &size);
89+
void setVelocitySize(const size_type &size);
9090
virtual void setVelocity(const dynamicgraph::Vector &vel);
9191
virtual void setSecondOrderIntegration();
9292
virtual void setNoIntegration();
@@ -151,7 +151,7 @@ class SOT_CORE_EXPORT Device : public Entity {
151151

152152
private:
153153
sigtime_t lastTimeControlWasRead_;
154-
int controlSize_;
154+
size_type controlSize_;
155155
// Intermediate variable to avoid dynamic allocation
156156
dynamicgraph::Vector forceZero6;
157157
};

include/sot/core/exception-abstract.hh

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <string> /* Classe string. */
2121

2222
#include "sot/core/api.hh"
23+
#include <sot/core/fwd.hh>
2324

2425
// Uncomment this macros to have lines parameter on the throw display
2526
// #define SOT_EXCEPTION_PASSING_PARAM
@@ -55,7 +56,7 @@ class SOT_CORE_EXPORT ExceptionAbstract : public std::exception {
5556
protected:
5657
/** Error code.
5758
* \sa ErrorCodeEnum */
58-
int code;
59+
size_type code;
5960

6061
/** Error message (can be empty). */
6162
std::string message;
@@ -65,11 +66,11 @@ class SOT_CORE_EXPORT ExceptionAbstract : public std::exception {
6566
ExceptionAbstract(void);
6667

6768
public:
68-
ExceptionAbstract(const int &code, const std::string &msg = "");
69+
ExceptionAbstract(const size_type &code, const std::string &msg = "");
6970
virtual ~ExceptionAbstract(void) throw() {}
7071

7172
/** Access to the error code. */
72-
int getCode(void);
73+
size_type getCode(void);
7374

7475
/** Reference access to the error message (can be empty). */
7576
const std::string &getStringMessage(void);
@@ -88,17 +89,17 @@ class SOT_CORE_EXPORT ExceptionAbstract : public std::exception {
8889
public:
8990
class Param {
9091
public:
91-
static const int BUFFER_SIZE = 80;
92+
static const size_type BUFFER_SIZE = 80;
9293

9394
const char *functionPTR;
9495
char function[BUFFER_SIZE];
95-
int line;
96+
size_type line;
9697
const char *filePTR;
9798
char file[BUFFER_SIZE];
9899
bool pointersSet, set;
99100

100101
public:
101-
Param(const int &_line, const char *_function, const char *_file);
102+
Param(const size_type &_line, const char *_function, const char *_file);
102103
Param(void) : pointersSet(false), set(false) {}
103104
Param &initCopy(const Param &p);
104105
};

include/sot/core/exp-moving-avg.hh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class SOT_CORE_DLLAPI ExpMovingAvg : public Entity {
3535

3636
public:
3737
SignalPtr<dynamicgraph::Vector, sigtime_t> updateSIN;
38-
SignalTimeDependent<int, sigtime_t> refresherSINTERN;
38+
SignalTimeDependent<size_type, sigtime_t> refresherSINTERN;
3939
SignalTimeDependent<dynamicgraph::Vector, sigtime_t> averageSOUT;
4040

4141
public:

0 commit comments

Comments
 (0)