From c9af71981f8b4177b4b5408ca5f34eea6db6fe8d Mon Sep 17 00:00:00 2001 From: Silvio Traversaro Date: Mon, 18 Dec 2023 17:48:36 +0100 Subject: [PATCH] Remove use of yarp::os::IConfig interface --- .../iCub/learningMachine/DatasetRecorder.h | 2 +- .../iCub/learningMachine/FixedRangeScaler.h | 2 +- .../iCub/learningMachine/IFixedSizeLearner.h | 2 +- .../learningMachine/IFixedSizeTransformer.h | 2 +- .../iCub/learningMachine/IMachineLearner.h | 19 +++++++++++++++++-- .../include/iCub/learningMachine/IScaler.h | 6 +++--- .../iCub/learningMachine/ITransformer.h | 5 ++--- .../iCub/learningMachine/LSSVMLearner.h | 7 +++---- .../iCub/learningMachine/LinearGPRLearner.h | 2 +- .../iCub/learningMachine/LinearScaler.h | 2 +- .../include/iCub/learningMachine/Normalizer.h | 2 +- .../include/iCub/learningMachine/RLSLearner.h | 2 +- .../iCub/learningMachine/RandomFeature.h | 2 +- .../iCub/learningMachine/ScaleTransformer.h | 2 +- .../learningMachine/SparseSpectrumFeature.h | 2 +- .../iCub/learningMachine/Standardizer.h | 2 +- .../camCalib/include/iCub/ICalibTool.h | 5 +---- .../camCalib/include/iCub/PinholeCalibTool.h | 1 - .../include/iCub/SphericalCalibTool.h | 2 -- .../include/iCub/ICalibTool.h | 5 +---- .../include/iCub/PinholeCalibTool.h | 1 - .../include/iCub/SphericalCalibTool.h | 2 -- .../dualCamCalib/include/iCub/ICalibTool.h | 5 +---- .../include/iCub/PinholeCalibTool.h | 1 - .../include/iCub/SphericalCalibTool.h | 2 -- src/modules/learningMachine/QUICKSTART | 2 +- .../iCub/learningMachine/IEventListener.h | 6 ++---- .../iCub/learningMachine/IPortEventListener.h | 2 +- 28 files changed, 44 insertions(+), 51 deletions(-) diff --git a/src/libraries/learningMachine/include/iCub/learningMachine/DatasetRecorder.h b/src/libraries/learningMachine/include/iCub/learningMachine/DatasetRecorder.h index a9f96c5f78..41f9d92a9a 100644 --- a/src/libraries/learningMachine/include/iCub/learningMachine/DatasetRecorder.h +++ b/src/libraries/learningMachine/include/iCub/learningMachine/DatasetRecorder.h @@ -143,7 +143,7 @@ class DatasetRecorder : public IMachineLearner { virtual void readBottle(yarp::os::Bottle& bot); /* - * Inherited from IConfig. + * Inherited from IMachineLearner. */ virtual bool configure(yarp::os::Searchable& config); }; diff --git a/src/libraries/learningMachine/include/iCub/learningMachine/FixedRangeScaler.h b/src/libraries/learningMachine/include/iCub/learningMachine/FixedRangeScaler.h index 6b275e06a5..7134f70bc2 100644 --- a/src/libraries/learningMachine/include/iCub/learningMachine/FixedRangeScaler.h +++ b/src/libraries/learningMachine/include/iCub/learningMachine/FixedRangeScaler.h @@ -91,7 +91,7 @@ class FixedRangeScaler : public IScaler { virtual std::string getInfo(); /* - * Inherited from IConfig. + * Inherited from IScaler. */ virtual bool configure(yarp::os::Searchable& config); diff --git a/src/libraries/learningMachine/include/iCub/learningMachine/IFixedSizeLearner.h b/src/libraries/learningMachine/include/iCub/learningMachine/IFixedSizeLearner.h index 3843fb511b..760bcaecd4 100644 --- a/src/libraries/learningMachine/include/iCub/learningMachine/IFixedSizeLearner.h +++ b/src/libraries/learningMachine/include/iCub/learningMachine/IFixedSizeLearner.h @@ -146,7 +146,7 @@ class IFixedSizeLearner : public IMachineLearner { virtual std::string getConfigHelp(); /* - * Inherited from IConfig. + * Inherited from IMachineLearner. */ virtual bool configure(yarp::os::Searchable& config); diff --git a/src/libraries/learningMachine/include/iCub/learningMachine/IFixedSizeTransformer.h b/src/libraries/learningMachine/include/iCub/learningMachine/IFixedSizeTransformer.h index cb8c4d5b82..ec74ae68e8 100644 --- a/src/libraries/learningMachine/include/iCub/learningMachine/IFixedSizeTransformer.h +++ b/src/libraries/learningMachine/include/iCub/learningMachine/IFixedSizeTransformer.h @@ -148,7 +148,7 @@ class IFixedSizeTransformer : public ITransformer { virtual std::string getConfigHelp(); /* - * Inherited from IConfig. + * Inherited from ITransformer. */ virtual bool configure(yarp::os::Searchable& config); diff --git a/src/libraries/learningMachine/include/iCub/learningMachine/IMachineLearner.h b/src/libraries/learningMachine/include/iCub/learningMachine/IMachineLearner.h index 52a76b9277..374a9f9980 100644 --- a/src/libraries/learningMachine/include/iCub/learningMachine/IMachineLearner.h +++ b/src/libraries/learningMachine/include/iCub/learningMachine/IMachineLearner.h @@ -23,7 +23,6 @@ #include #include -#include #include #include #include @@ -86,7 +85,7 @@ namespace learningmachine { * */ -class IMachineLearner : public yarp::os::IConfig, public yarp::os::Portable { +class IMachineLearner : public yarp::os::Portable { protected: /** * The name of this type of machine learner. @@ -122,6 +121,22 @@ class IMachineLearner : public yarp::os::IConfig, public yarp::os::Portable { */ virtual ~IMachineLearner() { } + + /** + * Initialize the object. + */ + virtual bool open(yarp::os::Searchable& config) {return true;} + + /** + * Shut the object down. + */ + virtual bool close() {return true;} + + /** + * Change parameters. + */ + virtual bool configure(yarp::os::Searchable& config) {return false;} + /** * Provide the learning machine with an example of the desired mapping. * diff --git a/src/libraries/learningMachine/include/iCub/learningMachine/IScaler.h b/src/libraries/learningMachine/include/iCub/learningMachine/IScaler.h index 632c9bd241..6eaed5839e 100644 --- a/src/libraries/learningMachine/include/iCub/learningMachine/IScaler.h +++ b/src/libraries/learningMachine/include/iCub/learningMachine/IScaler.h @@ -21,7 +21,7 @@ #include -#include +#include namespace iCub { namespace learningmachine { @@ -38,7 +38,7 @@ namespace learningmachine { * */ -class IScaler : public yarp::os::IConfig { +class IScaler { protected: /** * The offset for the linear transformation. @@ -175,7 +175,7 @@ class IScaler : public yarp::os::IConfig { virtual bool fromString(const std::string& str); /* - * Inherited from IConfig. + * Configure. */ virtual bool configure(yarp::os::Searchable& config); }; diff --git a/src/libraries/learningMachine/include/iCub/learningMachine/ITransformer.h b/src/libraries/learningMachine/include/iCub/learningMachine/ITransformer.h index 56fb75fcdf..2724094ce0 100644 --- a/src/libraries/learningMachine/include/iCub/learningMachine/ITransformer.h +++ b/src/libraries/learningMachine/include/iCub/learningMachine/ITransformer.h @@ -22,7 +22,6 @@ #include #include -#include #include #include #include @@ -55,7 +54,7 @@ namespace learningmachine { * */ -class ITransformer : public yarp::os::IConfig, public yarp::os::Portable { +class ITransformer : public yarp::os::Portable { protected: /** * The name of this type of transformer. @@ -164,7 +163,7 @@ class ITransformer : public yarp::os::IConfig, public yarp::os::Portable { virtual ITransformer* clone() = 0; /* - * Inherited from IConfig. + * Configure. */ virtual bool configure(yarp::os::Searchable& config) { return true; } diff --git a/src/libraries/learningMachine/include/iCub/learningMachine/LSSVMLearner.h b/src/libraries/learningMachine/include/iCub/learningMachine/LSSVMLearner.h index e057378388..20c5ef17f0 100644 --- a/src/libraries/learningMachine/include/iCub/learningMachine/LSSVMLearner.h +++ b/src/libraries/learningMachine/include/iCub/learningMachine/LSSVMLearner.h @@ -22,7 +22,6 @@ #include #include -#include #include #include "iCub/learningMachine/IFixedSizeLearner.h" @@ -31,7 +30,7 @@ namespace iCub { namespace learningmachine { -class Kernel : public yarp::os::IConfig { +class Kernel { private: std::string name; public: @@ -77,7 +76,7 @@ class RBFKernel : public Kernel { } /* - * Inherited from IConfig. + * Inherited from Kernel. */ virtual bool configure(yarp::os::Searchable& config) { bool success = false; @@ -237,7 +236,7 @@ class LSSVMLearner : public IFixedSizeLearner { void setCoDomainSize(unsigned int size); /* - * Inherited from IConfig. + * Inherited from IMachineLearner. */ virtual bool configure(yarp::os::Searchable& config); diff --git a/src/libraries/learningMachine/include/iCub/learningMachine/LinearGPRLearner.h b/src/libraries/learningMachine/include/iCub/learningMachine/LinearGPRLearner.h index a3cacacb22..fcbe1a46d8 100644 --- a/src/libraries/learningMachine/include/iCub/learningMachine/LinearGPRLearner.h +++ b/src/libraries/learningMachine/include/iCub/learningMachine/LinearGPRLearner.h @@ -181,7 +181,7 @@ class LinearGPRLearner : public IFixedSizeLearner { double getSigma(); /* - * Inherited from IConfig. + * Inherited from IMachineLearner. */ virtual bool configure(yarp::os::Searchable& config); diff --git a/src/libraries/learningMachine/include/iCub/learningMachine/LinearScaler.h b/src/libraries/learningMachine/include/iCub/learningMachine/LinearScaler.h index 18400db322..9a78f78ad4 100644 --- a/src/libraries/learningMachine/include/iCub/learningMachine/LinearScaler.h +++ b/src/libraries/learningMachine/include/iCub/learningMachine/LinearScaler.h @@ -62,7 +62,7 @@ class LinearScaler : public IScaler { virtual std::string getInfo(); /* - * Inherited from IConfig. + * Inherited from IScaler. */ virtual bool configure(yarp::os::Searchable& config); diff --git a/src/libraries/learningMachine/include/iCub/learningMachine/Normalizer.h b/src/libraries/learningMachine/include/iCub/learningMachine/Normalizer.h index 5df74e5226..7faa6d13ff 100644 --- a/src/libraries/learningMachine/include/iCub/learningMachine/Normalizer.h +++ b/src/libraries/learningMachine/include/iCub/learningMachine/Normalizer.h @@ -89,7 +89,7 @@ class Normalizer : public IScaler { virtual std::string getInfo(); /* - * Inherited from IConfig. + * Inherited from IScaler. */ virtual bool configure(yarp::os::Searchable& config); diff --git a/src/libraries/learningMachine/include/iCub/learningMachine/RLSLearner.h b/src/libraries/learningMachine/include/iCub/learningMachine/RLSLearner.h index 6d47483c54..0fd3ce82dd 100644 --- a/src/libraries/learningMachine/include/iCub/learningMachine/RLSLearner.h +++ b/src/libraries/learningMachine/include/iCub/learningMachine/RLSLearner.h @@ -168,7 +168,7 @@ class RLSLearner : public IFixedSizeLearner { double getLambda(); /* - * Inherited from IConfig. + * Inherited from IMachineLearner. */ virtual bool configure(yarp::os::Searchable& config); }; diff --git a/src/libraries/learningMachine/include/iCub/learningMachine/RandomFeature.h b/src/libraries/learningMachine/include/iCub/learningMachine/RandomFeature.h index 0be4e6e50a..10a78935b1 100644 --- a/src/libraries/learningMachine/include/iCub/learningMachine/RandomFeature.h +++ b/src/libraries/learningMachine/include/iCub/learningMachine/RandomFeature.h @@ -122,7 +122,7 @@ class RandomFeature : public IFixedSizeTransformer { virtual void reset(); /* - * Inherited from IConfig. + * Inherited from ITransformer. */ virtual bool configure(yarp::os::Searchable &config); diff --git a/src/libraries/learningMachine/include/iCub/learningMachine/ScaleTransformer.h b/src/libraries/learningMachine/include/iCub/learningMachine/ScaleTransformer.h index 27220bd1ad..dadc6cc8ce 100644 --- a/src/libraries/learningMachine/include/iCub/learningMachine/ScaleTransformer.h +++ b/src/libraries/learningMachine/include/iCub/learningMachine/ScaleTransformer.h @@ -154,7 +154,7 @@ class ScaleTransformer : public IFixedSizeTransformer { virtual void reset(); /* - * Inherited from IConfig. + * Inherited from ITransformer. */ virtual bool configure(yarp::os::Searchable &config); diff --git a/src/libraries/learningMachine/include/iCub/learningMachine/SparseSpectrumFeature.h b/src/libraries/learningMachine/include/iCub/learningMachine/SparseSpectrumFeature.h index f821d23b5d..7136cd422f 100644 --- a/src/libraries/learningMachine/include/iCub/learningMachine/SparseSpectrumFeature.h +++ b/src/libraries/learningMachine/include/iCub/learningMachine/SparseSpectrumFeature.h @@ -127,7 +127,7 @@ class SparseSpectrumFeature : public IFixedSizeTransformer { virtual void reset(); /* - * Inherited from IConfig. + * Inherited from ITransformer. */ virtual bool configure(yarp::os::Searchable &config); diff --git a/src/libraries/learningMachine/include/iCub/learningMachine/Standardizer.h b/src/libraries/learningMachine/include/iCub/learningMachine/Standardizer.h index 83e0539ac5..23b382b452 100644 --- a/src/libraries/learningMachine/include/iCub/learningMachine/Standardizer.h +++ b/src/libraries/learningMachine/include/iCub/learningMachine/Standardizer.h @@ -102,7 +102,7 @@ class Standardizer : public IScaler { virtual std::string getInfo(); /* - * Inherited from IConfig + * Inherited from IScaler */ virtual bool configure(yarp::os::Searchable& config); diff --git a/src/modules/camCalib/include/iCub/ICalibTool.h b/src/modules/camCalib/include/iCub/ICalibTool.h index 8c5ed5d6ae..8e83391245 100644 --- a/src/modules/camCalib/include/iCub/ICalibTool.h +++ b/src/modules/camCalib/include/iCub/ICalibTool.h @@ -11,17 +11,14 @@ // yarp #include -#include /** * Interface to calibrate and project input image based on camera's internal parameters and projection mode\n */ -class ICalibTool : public yarp::os::IConfig +class ICalibTool { public: - - // IConfig virtual bool open (yarp::os::Searchable &config) = 0; virtual bool close () = 0; virtual bool configure (yarp::os::Searchable &config) = 0; diff --git a/src/modules/camCalib/include/iCub/PinholeCalibTool.h b/src/modules/camCalib/include/iCub/PinholeCalibTool.h index a713afd2b0..efe1017910 100644 --- a/src/modules/camCalib/include/iCub/PinholeCalibTool.h +++ b/src/modules/camCalib/include/iCub/PinholeCalibTool.h @@ -23,7 +23,6 @@ // yarp //#include #include -#include #include #include diff --git a/src/modules/camCalib/include/iCub/SphericalCalibTool.h b/src/modules/camCalib/include/iCub/SphericalCalibTool.h index 965ddf9b05..a7e62f8fec 100644 --- a/src/modules/camCalib/include/iCub/SphericalCalibTool.h +++ b/src/modules/camCalib/include/iCub/SphericalCalibTool.h @@ -12,7 +12,6 @@ // yarp //#include #include -#include #include // opencv @@ -56,7 +55,6 @@ class SphericalCalibTool : public ICalibTool SphericalCalibTool(); virtual ~SphericalCalibTool(); - // IConfig virtual bool open (yarp::os::Searchable &config); virtual bool close(); virtual bool configure (yarp::os::Searchable &config); diff --git a/src/modules/camCalibWithPose/include/iCub/ICalibTool.h b/src/modules/camCalibWithPose/include/iCub/ICalibTool.h index 8c5ed5d6ae..8e83391245 100644 --- a/src/modules/camCalibWithPose/include/iCub/ICalibTool.h +++ b/src/modules/camCalibWithPose/include/iCub/ICalibTool.h @@ -11,17 +11,14 @@ // yarp #include -#include /** * Interface to calibrate and project input image based on camera's internal parameters and projection mode\n */ -class ICalibTool : public yarp::os::IConfig +class ICalibTool { public: - - // IConfig virtual bool open (yarp::os::Searchable &config) = 0; virtual bool close () = 0; virtual bool configure (yarp::os::Searchable &config) = 0; diff --git a/src/modules/camCalibWithPose/include/iCub/PinholeCalibTool.h b/src/modules/camCalibWithPose/include/iCub/PinholeCalibTool.h index a713afd2b0..efe1017910 100644 --- a/src/modules/camCalibWithPose/include/iCub/PinholeCalibTool.h +++ b/src/modules/camCalibWithPose/include/iCub/PinholeCalibTool.h @@ -23,7 +23,6 @@ // yarp //#include #include -#include #include #include diff --git a/src/modules/camCalibWithPose/include/iCub/SphericalCalibTool.h b/src/modules/camCalibWithPose/include/iCub/SphericalCalibTool.h index 965ddf9b05..a7e62f8fec 100644 --- a/src/modules/camCalibWithPose/include/iCub/SphericalCalibTool.h +++ b/src/modules/camCalibWithPose/include/iCub/SphericalCalibTool.h @@ -12,7 +12,6 @@ // yarp //#include #include -#include #include // opencv @@ -56,7 +55,6 @@ class SphericalCalibTool : public ICalibTool SphericalCalibTool(); virtual ~SphericalCalibTool(); - // IConfig virtual bool open (yarp::os::Searchable &config); virtual bool close(); virtual bool configure (yarp::os::Searchable &config); diff --git a/src/modules/dualCamCalib/include/iCub/ICalibTool.h b/src/modules/dualCamCalib/include/iCub/ICalibTool.h index 8c5ed5d6ae..8e83391245 100644 --- a/src/modules/dualCamCalib/include/iCub/ICalibTool.h +++ b/src/modules/dualCamCalib/include/iCub/ICalibTool.h @@ -11,17 +11,14 @@ // yarp #include -#include /** * Interface to calibrate and project input image based on camera's internal parameters and projection mode\n */ -class ICalibTool : public yarp::os::IConfig +class ICalibTool { public: - - // IConfig virtual bool open (yarp::os::Searchable &config) = 0; virtual bool close () = 0; virtual bool configure (yarp::os::Searchable &config) = 0; diff --git a/src/modules/dualCamCalib/include/iCub/PinholeCalibTool.h b/src/modules/dualCamCalib/include/iCub/PinholeCalibTool.h index a713afd2b0..efe1017910 100644 --- a/src/modules/dualCamCalib/include/iCub/PinholeCalibTool.h +++ b/src/modules/dualCamCalib/include/iCub/PinholeCalibTool.h @@ -23,7 +23,6 @@ // yarp //#include #include -#include #include #include diff --git a/src/modules/dualCamCalib/include/iCub/SphericalCalibTool.h b/src/modules/dualCamCalib/include/iCub/SphericalCalibTool.h index 965ddf9b05..a7e62f8fec 100644 --- a/src/modules/dualCamCalib/include/iCub/SphericalCalibTool.h +++ b/src/modules/dualCamCalib/include/iCub/SphericalCalibTool.h @@ -12,7 +12,6 @@ // yarp //#include #include -#include #include // opencv @@ -56,7 +55,6 @@ class SphericalCalibTool : public ICalibTool SphericalCalibTool(); virtual ~SphericalCalibTool(); - // IConfig virtual bool open (yarp::os::Searchable &config); virtual bool close(); virtual bool configure (yarp::os::Searchable &config); diff --git a/src/modules/learningMachine/QUICKSTART b/src/modules/learningMachine/QUICKSTART index c517d95093..b796303c0e 100644 --- a/src/modules/learningMachine/QUICKSTART +++ b/src/modules/learningMachine/QUICKSTART @@ -320,7 +320,7 @@ A better strategy is to interface with the desired subtype indirectly using the abstract base classes. In this case, configuration cannot be done directly using member functions, as each subtype will have different configurable parameters and thus different functions. Instead, configuration is done by -sending Property instances to the configure method (cf. the YARP IConfig class). +sending Property instances to the configure method. This strategy already guarantees that changing to another subtype only involves a reasonably small amount of changes in your program. Changing to another subtype will, however, require a recompilation of the program. Further, features diff --git a/src/modules/learningMachine/include/iCub/learningMachine/IEventListener.h b/src/modules/learningMachine/include/iCub/learningMachine/IEventListener.h index d03cd30797..ab461a3f06 100644 --- a/src/modules/learningMachine/include/iCub/learningMachine/IEventListener.h +++ b/src/modules/learningMachine/include/iCub/learningMachine/IEventListener.h @@ -19,8 +19,6 @@ #ifndef LM_IEVENTLISTENER__ #define LM_IEVENTLISTENER__ -#include - #include "iCub/learningMachine/IEvent.h" #include "iCub/learningMachine/TrainEvent.h" #include "iCub/learningMachine/PredictEvent.h" @@ -42,7 +40,7 @@ class IEvent; class TrainEvent; class PredictEvent; -class IEventListener : public yarp::os::IConfig { +class IEventListener { protected: /** * The name of this type of EventListener. @@ -133,7 +131,7 @@ class IEventListener : public yarp::os::IConfig { } /* - * Inherited from IConfig. + * Configure. */ virtual bool configure(yarp::os::Searchable& config); diff --git a/src/modules/learningMachine/include/iCub/learningMachine/IPortEventListener.h b/src/modules/learningMachine/include/iCub/learningMachine/IPortEventListener.h index fe7b834d78..c0c747d651 100644 --- a/src/modules/learningMachine/include/iCub/learningMachine/IPortEventListener.h +++ b/src/modules/learningMachine/include/iCub/learningMachine/IPortEventListener.h @@ -101,7 +101,7 @@ class IPortEventListener : public IEventListener { } /* - * Inherited from IConfig. + * Configure. */ virtual bool configure(yarp::os::Searchable& config);