Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Const correctness #1704

Merged
merged 11 commits into from
May 28, 2018
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ list(APPEND CMAKE_MODULE_PATH ${YARP_MODULE_PATH})

# Main project
project(YARP
VERSION 2.3.73.3
VERSION 2.3.73.4
LANGUAGES C CXX)
set(PROJECT_DESCRIPTION "YARP: A thin middleware for humanoid robots and more")

Expand Down
4 changes: 2 additions & 2 deletions bindings/yarp.i
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@
%ignore yarp::sig::Image::pixel(int,int) const;
%ignore yarp::sig::Image::getRow(int) const;
%ignore yarp::sig::Image::getIplImage() const;
%ignore yarp::sig::Image::getReadType();
%ignore yarp::sig::Vector::getType();
%ignore yarp::sig::Image::getReadType() const;
%ignore yarp::sig::Vector::getType() const;
%ignore yarp::os::Property::put(const char *,Value *);
%ignore yarp::os::Bottle::add(Value *);
%rename(toString) std::string::operator const char *() const;
Expand Down
15 changes: 9 additions & 6 deletions doc/release/v3_0_0.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,9 @@ Important Changes
* `Thread` `setOptions()` and `setDefaultStackSize()` are now deprecated and
no longer doing anything.
* The `YARP_STACK_SIZE` environment variable is no longer used.

#### `YARP_sig`

* The file `yarp/sig/IplImage.h` is deprecated, use opencv headers instead.
* Added the `yarp::sig::PointCloud` class. See the documentation for details.
* `Portable::getType()` became `Portable::getType() const`(#1617).
* `PortWriter::getWriteType()` became `PortWriter::getWriteType() const`(#1621).
* `PortReader::getReadType()` became `PortReader::getReadType() const`(#1616).

#### `YARP_dev`

Expand Down Expand Up @@ -149,10 +147,15 @@ Important Changes
- `IVelocityControl2Raw` in favour of `IVelocityControlRaw`.
- `IVelocityControl2` in favour of `IVelocityControl`.
- `ImplementVelocityControl2` in favour of `ImplementVelocityControl`.
* `IPositionDirectRaw::setPositionsRaw(const int, const int*, double*)` became
`IPositionDirectRaw::setPositionsRaw(const int, const int*, const double*)`.
* `IPositionDirect::setPositions(const int, const int*, double*)` became
`IPositionDirect::setPositions(const int, const int*, const double*)`(#1351).

#### `YARP_sig`

* The file `yarp/sig/IplImage.h` is deprecated, use opencv headers instead.
* Added the `yarp::sig::PointCloud` class. See the documentation for details.

#### `YARP_manager`

Expand Down Expand Up @@ -251,7 +254,7 @@ New Features
* Added realsense2 device.


### bindings
### Bindings

#### IMotorEncoders interface bindings

Expand Down
2 changes: 1 addition & 1 deletion src/devices/fakeMotionControl/fakeMotionControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2865,7 +2865,7 @@ bool FakeMotionControl::setPositionRaw(int j, double ref)
return true;
}

bool FakeMotionControl::setPositionsRaw(const int n_joint, const int *joints, double *refs)
bool FakeMotionControl::setPositionsRaw(const int n_joint, const int *joints, const double *refs)
{
for(int i=0; i< n_joint; i++)
{
Expand Down
2 changes: 1 addition & 1 deletion src/devices/fakeMotionControl/fakeMotionControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ class yarp::dev::FakeMotionControl : public DeviceDriver,

// PositionDirect Interface
virtual bool setPositionRaw(int j, double ref) override;
virtual bool setPositionsRaw(const int n_joint, const int *joints, double *refs) override;
virtual bool setPositionsRaw(const int n_joint, const int *joints, const double *refs) override;
virtual bool setPositionsRaw(const double *refs) override;
virtual bool getRefPositionRaw(const int joint, double *ref) override;
virtual bool getRefPositionsRaw(double *refs) override;
Expand Down
2 changes: 1 addition & 1 deletion src/idls/rosmsg/src/RosTypeCodeGenYarp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,7 @@ bool RosTypeCodeGenYarp::endType(const std::string& tname,
fprintf(out, "\n");

fprintf(out, " // Name the class, ROS will need this\n");
fprintf(out, " yarp::os::Type getType() override\n");
fprintf(out, " yarp::os::Type getType() const override\n");
fprintf(out, " {\n");
fprintf(out, " yarp::os::Type typ = yarp::os::Type::byName(\"%s\", \"%s\");\n", dbl_name.c_str(), dbl_name.c_str());
fprintf(out, " typ.addProperty(\"md5sum\", yarp::os::Value(\"%s\"));\n", field.checksum.c_str());
Expand Down
2 changes: 1 addition & 1 deletion src/libYARP_OS/include/yarp/os/PortReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class YARP_OS_API PortReader
*/
virtual bool read(ConnectionReader& reader) = 0;

virtual Type getReadType();
virtual Type getReadType() const;
};

} // namespace os
Expand Down
2 changes: 1 addition & 1 deletion src/libYARP_OS/include/yarp/os/PortWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class YARP_OS_API yarp::os::PortWriter {
*/
virtual void onCommencement();

virtual Type getWriteType() { return Type::anon(); }
virtual Type getWriteType() const { return Type::anon(); }
};

#endif // YARP_OS_PORTWRITER_H
2 changes: 1 addition & 1 deletion src/libYARP_OS/include/yarp/os/Portable.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class YARP_OS_API yarp::os::Portable : public PortReader, public PortWriter
virtual bool read(ConnectionReader& reader) override = 0;
virtual bool write(ConnectionWriter& writer) override = 0;

virtual Type getType() { return getReadType(); }
virtual Type getType() const { return getReadType(); }

/**
* Copy one portable to another, via writing and reading.
Expand Down
8 changes: 4 additions & 4 deletions src/libYARP_OS/include/yarp/os/Stamp.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,29 +46,29 @@ class YARP_OS_API Stamp : public Portable
*
* @return the sequence number.
*/
int getCount();
int getCount() const;

/**
* Get the time stamp.
*
* @return the time stamp
*/
double getTime();
double getTime() const;

/**
* Check if this Stamp is valid.
*
* @return true if this is a valid Stamp
*/
bool isValid();
bool isValid() const;

/**
* Get the maximum sequence number, after which an incrementing sequence
* should return to zero.
*
* @return the maximum sequence number.
*/
int getMaxCount();
int getMaxCount() const;

/**
* Set the timestamp to the current time, and increment the sequence number
Expand Down
2 changes: 1 addition & 1 deletion src/libYARP_OS/src/PortReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ yarp::os::PortReader::~PortReader()
{
}

yarp::os::Type yarp::os::PortReader::getReadType()
yarp::os::Type yarp::os::PortReader::getReadType() const
{
return Type::anon();
}
8 changes: 4 additions & 4 deletions src/libYARP_OS/src/Stamp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@ yarp::os::Stamp::Stamp()
timeStamp = 0;
}

int yarp::os::Stamp::getCount()
int yarp::os::Stamp::getCount() const
{
return sequenceNumber;
}

double yarp::os::Stamp::getTime()
double yarp::os::Stamp::getTime() const
{
return timeStamp;
}

bool yarp::os::Stamp::isValid()
bool yarp::os::Stamp::isValid() const
{
return sequenceNumber >= 0;
}
Expand Down Expand Up @@ -101,7 +101,7 @@ bool yarp::os::Stamp::write(ConnectionWriter& connection)
return !connection.isError();
}

int yarp::os::Stamp::getMaxCount()
int yarp::os::Stamp::getMaxCount() const
{
// a very conservative maximum
return 32767;
Expand Down
17 changes: 10 additions & 7 deletions src/libYARP_dev/include/yarp/dev/IPositionDirect.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@
* BSD-3-Clause license. See the accompanying LICENSE file for details.
*/


#ifndef YARP_IPOSITIONDIRECT_H
#define YARP_IPOSITIONDIRECT_H

#include <yarp/dev/api.h>

namespace yarp {
namespace dev {
class IPositionDirect;
Expand Down Expand Up @@ -58,7 +61,7 @@ class YARP_dev_API yarp::dev::IPositionDirect
* refs 10 30 40
* @return true/false on success/failure
*/
virtual bool setPositions(const int n_joint, const int *joints, double *refs)=0;
virtual bool setPositions(const int n_joint, const int *joints, const double *refs)=0;

/** Set new position for a set of axis.
* @param refs specifies the new reference points
Expand All @@ -75,7 +78,7 @@ class YARP_dev_API yarp::dev::IPositionDirect
* @param ref last reference sent using setPosition(s) functions
* @return true/false on success/failure
*/
virtual bool getRefPosition(const int joint, double *ref) {return false;};
virtual bool getRefPosition(const int joint, double *ref) {return false;}

/** Get the last position reference for all axes.
* This is the dual of setPositionsRaw and shall return only values sent using
Expand All @@ -86,7 +89,7 @@ class YARP_dev_API yarp::dev::IPositionDirect
* @param ref array containing last reference sent using setPosition(s) functions
* @return true/false on success/failure
*/
virtual bool getRefPositions(double *refs) {return false;};
virtual bool getRefPositions(double *refs) {return false;}

/** Get the last position reference for the specified group of axes.
* This is the dual of setPositionsRaw and shall return only values sent using
Expand All @@ -97,7 +100,7 @@ class YARP_dev_API yarp::dev::IPositionDirect
* @param ref array containing last reference sent using setPosition(s) functions
* @return true/false on success/failure
*/
virtual bool getRefPositions(const int n_joint, const int *joints, double *refs) {return false;};
virtual bool getRefPositions(const int n_joint, const int *joints, double *refs) {return false;}
};


Expand Down Expand Up @@ -142,7 +145,7 @@ class yarp::dev::IPositionDirectRaw
* refs 10 30 40
* @return true/false on success/failure
*/
virtual bool setPositionsRaw(const int n_joint, const int *joints, double *refs)=0;
virtual bool setPositionsRaw(const int n_joint, const int *joints, const double *refs)=0;


/** Set new position for a set of axes.
Expand All @@ -160,7 +163,7 @@ class yarp::dev::IPositionDirectRaw
* @param ref last reference sent using setPosition(s) functions
* @return true/false on success/failure
*/
virtual bool getRefPositionRaw(const int joint, double *ref) {return false;};
virtual bool getRefPositionRaw(const int joint, double *ref) {return false;}

/** Get the last position reference for all axes.
* This is the dual of setPositionsRaw and shall return only values sent using
Expand All @@ -183,7 +186,7 @@ class yarp::dev::IPositionDirectRaw
* @param ref array containing last reference sent using setPosition(s) functions
* @return true/false on success/failure
*/
virtual bool getRefPositionsRaw(const int n_joint, const int *joints, double *refs) {return false;};
virtual bool getRefPositionsRaw(const int n_joint, const int *joints, double *refs) {return false;}
};

#define VOCAB_POSITION_DIRECT VOCAB3('d','p','o')
Expand Down
4 changes: 2 additions & 2 deletions src/libYARP_dev/include/yarp/dev/IPositionDirectImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class YARP_dev_API yarp::dev::ImplementPositionDirect : public yarp::dev::IPosit

virtual bool getAxes(int *axes) override;
virtual bool setPosition(int j, double ref) override;
virtual bool setPositions(const int n_joint, const int *joints, double *refs) override;
virtual bool setPositions(const int n_joint, const int *joints, const double *refs) override;
virtual bool setPositions(const double *refs) override;
virtual bool getRefPosition(const int joint, double *ref) override;
virtual bool getRefPositions(double *refs) override;
Expand Down Expand Up @@ -103,7 +103,7 @@ class YARP_dev_API yarp::dev::StubImplPositionDirectRaw: public IPositionDirect
virtual bool setPosition(int j, double ref) override
{return NOT_YET_IMPLEMENTED("setPosition");}

virtual bool setPositions(const int n_joint, const int *joints, double *refs) override
virtual bool setPositions(const int n_joint, const int *joints, const double *refs) override
{return NOT_YET_IMPLEMENTED("setPositions");}

virtual bool setPositions(const double *refs) override
Expand Down
2 changes: 1 addition & 1 deletion src/libYARP_dev/src/IPositionDirectImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ bool ImplementPositionDirect::setPosition(int j, double ref)
return iPDirect->setPositionRaw(k, enc);
}

bool ImplementPositionDirect::setPositions(const int n_joint, const int *joints, double *refs)
bool ImplementPositionDirect::setPositions(const int n_joint, const int *joints, const double *refs)
{
int *tmp_joints = new int [nj];
double *tmp_refs = new double [nj];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3739,7 +3739,7 @@ bool ControlBoardRemapper::setPosition(int j, double ref)
return false;
}

bool ControlBoardRemapper::setPositions(const int n_joints, const int *joints, double *dpos)
bool ControlBoardRemapper::setPositions(const int n_joints, const int *joints, const double *dpos)
{
bool ret=true;
yarp::os::LockGuard(selectedJointsBuffers.mutex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ class ControlBoardRemapper : public yarp::dev::DeviceDriver,

virtual bool setPosition(int j, double ref) override;

virtual bool setPositions(const int n_joints, const int *joints, double *dpos) override;
virtual bool setPositions(const int n_joints, const int *joints, const double *dpos) override;

virtual bool setPositions(const double *refs) override;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4471,7 +4471,7 @@ bool ControlBoardWrapper::setPosition(int j, double ref)
return false;
}

bool ControlBoardWrapper::setPositions(const int n_joints, const int *joints, double *dpos)
bool ControlBoardWrapper::setPositions(const int n_joints, const int *joints, const double *dpos)
{
bool ret = true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1186,7 +1186,7 @@ class yarp::dev::ControlBoardWrapper: public yarp::dev::DeviceDriver,

virtual bool setPosition(int j, double ref) override;

virtual bool setPositions(const int n_joints, const int *joints, double *dpos) override;
virtual bool setPositions(const int n_joints, const int *joints, const double *dpos) override;

virtual bool setPositions(const double *refs) override;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2859,7 +2859,7 @@ class yarp::dev::RemoteControlBoard :
return true;
}

bool setPositions(const int n_joint, const int *joints, double *refs) override
bool setPositions(const int n_joint, const int *joints, const double *refs) override
{
if (!isLive()) return false;
CommandMessage& c = command_buffer.get();
Expand Down
2 changes: 1 addition & 1 deletion src/libYARP_math/include/yarp/math/Quaternion.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ class YARP_math_API yarp::math::Quaternion : public yarp::os::Portable
*/
virtual bool write(yarp::os::ConnectionWriter& connection) override;

virtual yarp::os::Type getType() override
virtual yarp::os::Type getType() const override
{
return yarp::os::Type::byName("yarp/quaternion");
}
Expand Down
2 changes: 1 addition & 1 deletion src/libYARP_math/include/yarp/math/Vec2D.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class YARP_math_API Vec2D : public yarp::os::Portable
*/
virtual bool write(yarp::os::ConnectionWriter& connection) override;

virtual yarp::os::Type getType() override
virtual yarp::os::Type getType() const override
{
return yarp::os::Type::byName("yarp/vec2D");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ class TickDuration : public yarp::os::idl::WirePortable
}

// Name the class, ROS will need this
yarp::os::Type getType() override
yarp::os::Type getType() const override
{
yarp::os::Type typ = yarp::os::Type::byName("TickDuration", "TickDuration");
typ.addProperty("md5sum", yarp::os::Value("4f8dc7710c22b42c7b09295dcda33fa0"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ class TickTime : public yarp::os::idl::WirePortable
}

// Name the class, ROS will need this
yarp::os::Type getType() override
yarp::os::Type getType() const override
{
yarp::os::Type typ = yarp::os::Type::byName("TickTime", "TickTime");
typ.addProperty("md5sum", yarp::os::Value("4f8dc7710c22b42c7b09295dcda33fa0"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ string id\n\
}

// Name the class, ROS will need this
yarp::os::Type getType() override
yarp::os::Type getType() const override
{
yarp::os::Type typ = yarp::os::Type::byName("actionlib_msgs/GoalID", "actionlib_msgs/GoalID");
typ.addProperty("md5sum", yarp::os::Value("302881f31927c1df708a2dbab0e80ee8"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ MSG: actionlib_msgs/GoalID\n\
}

// Name the class, ROS will need this
yarp::os::Type getType() override
yarp::os::Type getType() const override
{
yarp::os::Type typ = yarp::os::Type::byName("actionlib_msgs/GoalStatus", "actionlib_msgs/GoalStatus");
typ.addProperty("md5sum", yarp::os::Value("d388f9b87b3c471f784434d671988d4a"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ MSG: actionlib_msgs/GoalStatus\n\
}

// Name the class, ROS will need this
yarp::os::Type getType() override
yarp::os::Type getType() const override
{
yarp::os::Type typ = yarp::os::Type::byName("actionlib_msgs/GoalStatusArray", "actionlib_msgs/GoalStatusArray");
typ.addProperty("md5sum", yarp::os::Value("8b2b82f13216d0a8ea88bd3af735e619"));
Expand Down
Loading