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

namespace macros #755

Merged
merged 3 commits into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/include/jiminy/core/constraints/abstract_constraint.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace jiminy
friend Model;

public:
DISABLE_COPY(AbstractConstraintBase)
JIMINY_DISABLE_COPY(AbstractConstraintBase)

public:
explicit AbstractConstraintBase() = default;
Expand Down
2 changes: 1 addition & 1 deletion core/include/jiminy/core/constraints/distance_constraint.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace jiminy
class JIMINY_DLLAPI DistanceConstraint : public AbstractConstraintTpl<DistanceConstraint>
{
public:
DISABLE_COPY(DistanceConstraint)
JIMINY_DISABLE_COPY(DistanceConstraint)

auto shared_from_this() { return shared_from(this); }

Expand Down
2 changes: 1 addition & 1 deletion core/include/jiminy/core/constraints/frame_constraint.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace jiminy
class JIMINY_DLLAPI FrameConstraint : public AbstractConstraintTpl<FrameConstraint>
{
public:
DISABLE_COPY(FrameConstraint)
JIMINY_DISABLE_COPY(FrameConstraint)

auto shared_from_this() { return shared_from(this); }

Expand Down
2 changes: 1 addition & 1 deletion core/include/jiminy/core/constraints/joint_constraint.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace jiminy
class JIMINY_DLLAPI JointConstraint : public AbstractConstraintTpl<JointConstraint>
{
public:
DISABLE_COPY(JointConstraint)
JIMINY_DISABLE_COPY(JointConstraint)

auto shared_from_this() { return shared_from(this); }

Expand Down
2 changes: 1 addition & 1 deletion core/include/jiminy/core/constraints/sphere_constraint.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace jiminy
class JIMINY_DLLAPI SphereConstraint : public AbstractConstraintTpl<SphereConstraint>
{
public:
DISABLE_COPY(SphereConstraint)
JIMINY_DISABLE_COPY(SphereConstraint)

auto shared_from_this() { return shared_from(this); }

Expand Down
2 changes: 1 addition & 1 deletion core/include/jiminy/core/constraints/wheel_constraint.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace jiminy
class JIMINY_DLLAPI WheelConstraint : public AbstractConstraintTpl<WheelConstraint>
{
public:
DISABLE_COPY(WheelConstraint)
JIMINY_DISABLE_COPY(WheelConstraint)

auto shared_from_this() { return shared_from(this); }

Expand Down
2 changes: 1 addition & 1 deletion core/include/jiminy/core/control/abstract_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ namespace jiminy
};

public:
DISABLE_COPY(AbstractController)
JIMINY_DISABLE_COPY(AbstractController)

public:
explicit AbstractController() noexcept;
Expand Down
6 changes: 3 additions & 3 deletions core/include/jiminy/core/control/abstract_controller.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ namespace jiminy
{
if (isTelemetryConfigured_)
{
THROW_ERROR(bad_control_flow,
"Telemetry already initialized. Impossible to register new variables.");
JIMINY_THROW(bad_control_flow,
"Telemetry already initialized. Impossible to register new variables.");
}

// Check in local cache before.
Expand All @@ -23,7 +23,7 @@ namespace jiminy
{ return element.first == name; });
if (variableIt != variableRegistry_.end())
{
THROW_ERROR(bad_control_flow, "Variable '", name, "' already registered.");
JIMINY_THROW(bad_control_flow, "Variable '", name, "' already registered.");
}
variableRegistry_.emplace_back(name, &value);
}
Expand Down
2 changes: 1 addition & 1 deletion core/include/jiminy/core/control/controller_functor.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace jiminy
class FunctionalController : public AbstractController
{
public:
DISABLE_COPY(FunctionalController)
JIMINY_DISABLE_COPY(FunctionalController)

public:
/// \remark A valid 'callable' is a function pointer, functor or lambda with signature:
Expand Down
6 changes: 3 additions & 3 deletions core/include/jiminy/core/control/controller_functor.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace jiminy
{
if (!getIsInitialized())
{
THROW_ERROR(bad_control_flow, "Controller not initialized.");
JIMINY_THROW(bad_control_flow, "Controller not initialized.");
}

commandFun_(t, q, v, sensorMeasurements_, command);
Expand All @@ -43,10 +43,10 @@ namespace jiminy
{
if (!getIsInitialized())
{
THROW_ERROR(bad_control_flow, "Controller not initialized.");
JIMINY_THROW(bad_control_flow, "Controller not initialized.");
}

// Sensor data are already up-to-date
internalDynamicsFun_(t, q, v, sensorMeasurements_, uCustom);
}
}
}
4 changes: 2 additions & 2 deletions core/include/jiminy/core/engine/engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ namespace jiminy
struct JIMINY_DLLAPI RobotData
{
public:
DISABLE_COPY(RobotData)
JIMINY_DISABLE_COPY(RobotData)

/* Must move all definitions in source files to avoid compilation failure due to incomplete
destructor for objects managed by `unique_ptr` member variable with MSVC compiler.
Expand Down Expand Up @@ -497,7 +497,7 @@ namespace jiminy
};

public:
DISABLE_COPY(Engine)
JIMINY_DISABLE_COPY(Engine)

public:
explicit Engine() noexcept;
Expand Down
2 changes: 1 addition & 1 deletion core/include/jiminy/core/hardware/abstract_motor.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ namespace jiminy
};

public:
DISABLE_COPY(AbstractMotorBase)
JIMINY_DISABLE_COPY(AbstractMotorBase)

public:
/// \param[in] name Name of the motor.
Expand Down
4 changes: 2 additions & 2 deletions core/include/jiminy/core/hardware/abstract_sensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ namespace jiminy
};

public:
DISABLE_COPY(AbstractSensorBase)
JIMINY_DISABLE_COPY(AbstractSensorBase)

public:
/// \param[in] name Name of the sensor
Expand Down Expand Up @@ -317,7 +317,7 @@ namespace jiminy
class JIMINY_TEMPLATE_DLLAPI AbstractSensorTpl : public AbstractSensorBase
{
public:
DISABLE_COPY(AbstractSensorTpl)
JIMINY_DISABLE_COPY(AbstractSensorTpl)

public:
using AbstractSensorBase::AbstractSensorBase;
Expand Down
44 changes: 22 additions & 22 deletions core/include/jiminy/core/hardware/abstract_sensor.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ namespace jiminy
{
if (!isAttached_)
{
THROW_ERROR(bad_control_flow, "Sensor not attached to any robot.");
JIMINY_THROW(bad_control_flow, "Sensor not attached to any robot.");
}

auto robot = robot_.lock();
if (!robot || robot->getIsLocked())
{
THROW_ERROR(bad_control_flow,
"Robot is locked, probably because a simulation is running. "
"Please stop it before setting sensor value manually.");
JIMINY_THROW(bad_control_flow,
"Robot is locked, probably because a simulation is running. "
"Please stop it before setting sensor value manually.");
}

get() = value;
Expand All @@ -49,15 +49,15 @@ namespace jiminy
// Make sure the sensor is not already attached
if (isAttached_)
{
THROW_ERROR(
JIMINY_THROW(
bad_control_flow,
"Sensor already attached to a robot. Please 'detach' method before attaching it.");
}

// Make sure the robot still exists
if (robot.expired())
{
THROW_ERROR(bad_control_flow, "Robot pointer expired or unset.");
JIMINY_THROW(bad_control_flow, "Robot pointer expired or unset.");
}

// Copy references to the robot and shared data
Expand Down Expand Up @@ -98,7 +98,7 @@ namespace jiminy

if (!isAttached_)
{
THROW_ERROR(bad_control_flow, "Sensor not attached to any robot.");
JIMINY_THROW(bad_control_flow, "Sensor not attached to any robot.");
}

// Remove associated col in the shared data buffers
Expand Down Expand Up @@ -153,28 +153,28 @@ namespace jiminy
{
if (!sensor->isAttached_)
{
THROW_ERROR(bad_control_flow,
"Sensor '",
sensor->name_,
"' of type '",
type_,
"' not attached to any robot.");
JIMINY_THROW(bad_control_flow,
"Sensor '",
sensor->name_,
"' of type '",
type_,
"' not attached to any robot.");
}
}

// Make sure the robot still exists
if (robot_.expired())
{
THROW_ERROR(bad_control_flow, "Robot has been deleted. Impossible to reset sensors.");
JIMINY_THROW(bad_control_flow, "Robot has been deleted. Impossible to reset sensors.");
}

// Make sure that no simulation is already running
auto robot = robot_.lock();
if (robot && robot->getIsLocked())
{
THROW_ERROR(bad_control_flow,
"Robot already locked, probably because a simulation is running. "
"Please stop it before resetting sensors.");
JIMINY_THROW(bad_control_flow,
"Robot already locked, probably because a simulation is running. "
"Please stop it before resetting sensors.");
}

// Clear the shared data buffers
Expand Down Expand Up @@ -223,7 +223,7 @@ namespace jiminy
{
if (!isAttached_)
{
THROW_ERROR(bad_control_flow, "Sensor not attached to any robot.");
JIMINY_THROW(bad_control_flow, "Sensor not attached to any robot.");
}

for (AbstractSensorBase * sensor : sharedStorage_->sensors_)
Expand Down Expand Up @@ -371,7 +371,7 @@ namespace jiminy
{
if (idxLeft < 0)
{
THROW_ERROR(std::runtime_error, "No data old enough is available.");
JIMINY_THROW(std::runtime_error, "No data old enough is available.");
}
else if (baseSensorOptions_->delayInterpolationOrder == 0)
{
Expand All @@ -389,8 +389,8 @@ namespace jiminy
}
else
{
THROW_ERROR(not_implemented_error,
"`delayInterpolationOrder` must be either 0 or 1.");
JIMINY_THROW(not_implemented_error,
"`delayInterpolationOrder` must be either 0 or 1.");
}
}
else
Expand Down Expand Up @@ -443,7 +443,7 @@ namespace jiminy
{
if (!isAttached_)
{
THROW_ERROR(bad_control_flow, "Sensor not attached to any robot.");
JIMINY_THROW(bad_control_flow, "Sensor not attached to any robot.");
}

/* Make sure at least the requested delay plus the maximum time step is available to handle
Expand Down
4 changes: 2 additions & 2 deletions core/include/jiminy/core/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

// ************************************* Generic utilities ************************************* //

#define DISABLE_COPY(className) \
#define JIMINY_DISABLE_COPY(className) \
className(const className & other) = delete; \
className & operator=(const className & other) = delete;

Expand Down Expand Up @@ -81,7 +81,7 @@ namespace jiminy::internal
/* ANSI escape codes is used here as a cross-platform way to color text. For reference, see:
https://solarianprogrammer.com/2019/04/08/c-programming-ansi-escape-codes-windows-macos-linux-terminals/
*/
#define THROW_ERROR(exception, ...) \
#define JIMINY_THROW(exception, ...) \
throw exception( \
toString(jiminy::internal::extractFunctionName(__func__, BOOST_CURRENT_FUNCTION), \
"(" FILE_LINE "):\n", \
Expand Down
2 changes: 1 addition & 1 deletion core/include/jiminy/core/robot/model.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ namespace jiminy
};

public:
DISABLE_COPY(Model)
JIMINY_DISABLE_COPY(Model)

public:
explicit Model() noexcept;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ namespace jiminy::pinocchio_overload
It is always the case in theory but not sure in practice because of rounding errors. */
if ((data.Dinv.array() < 0.0).any())
{
THROW_ERROR(std::runtime_error, "Inertia matrix not positive definite.");
JIMINY_THROW(std::runtime_error, "Inertia matrix not positive definite.");
}

/* Compute sDUiJt := sqrt(D)^-1 * U^-1 * J.T
Expand Down
2 changes: 1 addition & 1 deletion core/include/jiminy/core/robot/robot.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace jiminy
using SensorTree = std::unordered_map<std::string, SensorVector>;

public:
DISABLE_COPY(Robot)
JIMINY_DISABLE_COPY(Robot)

public:
/// \param[in] name Name of the Robot.
Expand Down
2 changes: 1 addition & 1 deletion core/include/jiminy/core/solver/constraint_solvers.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ namespace jiminy
class JIMINY_DLLAPI PGSSolver : public AbstractConstraintSolver
{
public:
DISABLE_COPY(PGSSolver)
JIMINY_DISABLE_COPY(PGSSolver)

public:
explicit PGSSolver(const pinocchio::Model * model,
Expand Down
2 changes: 1 addition & 1 deletion core/include/jiminy/core/telemetry/telemetry_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace jiminy
class JIMINY_DLLAPI TelemetryData
{
public:
DISABLE_COPY(TelemetryData)
JIMINY_DISABLE_COPY(TelemetryData)

public:
explicit TelemetryData() = default;
Expand Down
8 changes: 4 additions & 4 deletions core/include/jiminy/core/telemetry/telemetry_data.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ namespace jiminy
// Check if registration is possible
if (!isRegisteringAvailable_)
{
THROW_ERROR(std::invalid_argument,
"Entry '",
name,
"' not found and registration is not available.");
JIMINY_THROW(std::invalid_argument,
"Entry '",
name,
"' not found and registration is not available.");
}

// Create new variable in registry
Expand Down
2 changes: 1 addition & 1 deletion core/include/jiminy/core/telemetry/telemetry_recorder.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace jiminy
class JIMINY_DLLAPI TelemetryRecorder
{
public:
DISABLE_COPY(TelemetryRecorder)
JIMINY_DISABLE_COPY(TelemetryRecorder)

public:
explicit TelemetryRecorder() = default;
Expand Down
2 changes: 1 addition & 1 deletion core/include/jiminy/core/telemetry/telemetry_sender.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace jiminy
class JIMINY_DLLAPI TelemetrySender
{
public:
DISABLE_COPY(TelemetrySender)
JIMINY_DISABLE_COPY(TelemetrySender)

public:
template<typename T>
Expand Down
Loading
Loading