Skip to content

Commit

Permalink
--move ManagedVisualSensor to separate header.
Browse files Browse the repository at this point in the history
  • Loading branch information
jturner65 committed Dec 27, 2024
1 parent 4602e2a commit f83fa04
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 58 deletions.
1 change: 1 addition & 0 deletions src/esp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@ set(
sensor/sensorWrappers/ManagedAudioSensor.h
sensor/sensorWrappers/ManagedSensorBase.h
sensor/sensorWrappers/ManagedSensorTemplates.h
sensor/sensorWrappers/ManagedVisualSensorBase.h
sensor/Sensor.cpp
sensor/Sensor.h
sensor/SensorFactory.cpp
Expand Down
1 change: 0 additions & 1 deletion src/esp/sensor/sensorWrappers/ManagedSensorBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

#include "esp/core/managedContainers/AbstractManagedObject.h"
#include "esp/sensor/Sensor.h"
#include "esp/sensor/VisualSensor.h"

namespace Cr = Corrade;
namespace Mn = Magnum;
Expand Down
57 changes: 0 additions & 57 deletions src/esp/sensor/sensorWrappers/ManagedSensorTemplates.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

#include "ManagedSensorBase.h"
#include "esp/sensor/Sensor.h"
#include "esp/sensor/VisualSensor.h"

namespace Cr = Corrade;
namespace Mn = Magnum;
Expand Down Expand Up @@ -95,62 +94,6 @@ class AbstractManagedSensor : public ManagedSensorBase {
ESP_SMART_POINTERS(AbstractManagedSensor<T>)
}; // class AbstractManagedSensor

/**
* @brief Base class template for wrapper for visual sensor objects of all kinds
* that extends AbstractManagedSensorAccess
*/

template <class T>
class AbstractManagedVisualSensor
: public esp::sensor::AbstractManagedSensor<T> {
public:
static_assert(std::is_base_of<esp::sensor::VisualSensor, T>::value,
"AbstractManagedVisualSensor :: Managed visual sensor object "
"type must be derived from esp::sensor::VisualSensor");

explicit AbstractManagedVisualSensor(const std::string& classKey)
: AbstractManagedSensor<T>(classKey) {}
// TODO Add appropriate abstract visual sensor getters/setters here

protected:
/**
* @brief Retrieve a comma-separated string holding the header values for
* the info returned for this managed object, type-specific.
*/

std::string getSensorObjInfoHeaderInternal() const override {
return "" + getVisualSensorObjInfoHeaderInternal();
}
/**
* @brief Retrieve a comma-separated string holding the header values for
* the info returned for this managed visual sensor, type-specific.
*/

virtual std::string getVisualSensorObjInfoHeaderInternal() const = 0;
/**
* @brief Specialization-specific extension of getObjectInfo, comma
* separated info ideal for saving to csv
*/
std::string getSensorObjInfoInternal(
CORRADE_UNUSED std::shared_ptr<VisualSensor>& sp) const override {
// TODO provide info stream for sensors
std::string res = Cr::Utility::formatString(
"{},{}", "VisualSensor", getVisualSensorObjInfoInternal());

return res;
}

/**
* @brief Specialization-specific extension of getSensorObjInfoInternal, comma
* separated info ideal for saving to csv
*/
virtual std::string getVisualSensorObjInfoInternal(
std::shared_ptr<T>& sp) const = 0;

public:
ESP_SMART_POINTERS(AbstractManagedVisualSensor<T>)
}; // class AbstractManagedVisualSensor

} // namespace sensor
} // namespace esp

Expand Down
76 changes: 76 additions & 0 deletions src/esp/sensor/sensorWrappers/ManagedVisualSensorBase.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// Copyright (c) Meta Platforms, Inc. and its affiliates.
// This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree.

#ifndef ESP_SENSOR_MANAGEDVISUALSENSORBASE_H_
#define ESP_SENSOR_MANAGEDVISUALSENSORBASE_H_

#include <Corrade/Utility/FormatStl.h>
#include <Corrade/Utility/Macros.h>

#include "ManagedSensorTemplates.h"
#include "esp/sensor/VisualSensor.h"

namespace esp {
namespace sensor {

/**
* @brief Base class template for wrapper for visual sensor objects of all kinds
* that extends AbstractManagedSensorAccess
*/

template <class T>
class AbstractManagedVisualSensor
: public esp::sensor::AbstractManagedSensor<T> {
public:
static_assert(std::is_base_of<esp::sensor::VisualSensor, T>::value,
"AbstractManagedVisualSensor :: Managed visual sensor object "
"type must be derived from esp::sensor::VisualSensor");

explicit AbstractManagedVisualSensor(const std::string& classKey)
: AbstractManagedSensor<T>(classKey) {}
// TODO Add appropriate abstract visual sensor getters/setters here

protected:
/**
* @brief Retrieve a comma-separated string holding the header values for
* the info returned for this managed object, type-specific.
*/

std::string getSensorObjInfoHeaderInternal() const override {
return "" + getVisualSensorObjInfoHeaderInternal();
}
/**
* @brief Retrieve a comma-separated string holding the header values for
* the info returned for this managed visual sensor, type-specific.
*/

virtual std::string getVisualSensorObjInfoHeaderInternal() const = 0;
/**
* @brief Specialization-specific extension of getObjectInfo, comma
* separated info ideal for saving to csv
*/
std::string getSensorObjInfoInternal(
CORRADE_UNUSED std::shared_ptr<VisualSensor>& sp) const override {
// TODO provide info stream for sensors
std::string res = Cr::Utility::formatString(
"{},{}", "VisualSensor", getVisualSensorObjInfoInternal());

return res;
}

/**
* @brief Specialization-specific extension of getSensorObjInfoInternal, comma
* separated info ideal for saving to csv
*/
virtual std::string getVisualSensorObjInfoInternal(
std::shared_ptr<T>& sp) const = 0;

public:
ESP_SMART_POINTERS(AbstractManagedVisualSensor<T>)
}; // class AbstractManagedVisualSensor

} // namespace sensor
} // namespace esp

#endif // ESP_SENSOR_MANAGEDVISUALSENSORBASE_H_

0 comments on commit f83fa04

Please sign in to comment.