Skip to content

Commit

Permalink
rewamped.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexis Duburcq committed Mar 19, 2024
1 parent 742ea59 commit a5421ef
Show file tree
Hide file tree
Showing 9 changed files with 86 additions and 34 deletions.
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 @@ -108,7 +108,7 @@ namespace jiminy
const std::string & getType() const { return type_; }

public:
static const std::string JIMINY_TEMPLATE_STATIC_MEMBER_DLLAPI type_;
static const std::string type_;
};
}

Expand Down
7 changes: 6 additions & 1 deletion core/include/jiminy/core/constraints/distance_constraint.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ namespace jiminy
{
class Model;

class DistanceConstraint;
template class JIMINY_TEMPLATE_INSTANTIATION_DLLAPI AbstractConstraintTpl<DistanceConstraint>;

class JIMINY_DLLAPI DistanceConstraint : public AbstractConstraintTpl<DistanceConstraint>
{
public:
Expand Down Expand Up @@ -46,9 +49,11 @@ namespace jiminy
std::array<Matrix6Xd, 2> frameJacobians_{};
};

#ifdef EXPORT_SYMBOLS
template<>
const std::string JIMINY_TEMPLATE_STATIC_MEMBER_DLLAPI
const std::string JIMINY_TEMPLATE_SPECIALIZATION_DLLEXPORT
AbstractConstraintTpl<DistanceConstraint>::type_;
#endif
}

#endif // end of JIMINY_TRANSMISSION_CONSTRAINT_H
7 changes: 6 additions & 1 deletion core/include/jiminy/core/constraints/frame_constraint.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ namespace jiminy
{
class Model;

class FrameConstraint;
template class JIMINY_TEMPLATE_INSTANTIATION_DLLAPI AbstractConstraintTpl<FrameConstraint>;

/// \brief This class implements the constraint for fixing a given frame wrt
/// world.
class JIMINY_DLLAPI FrameConstraint : public AbstractConstraintTpl<FrameConstraint>
Expand Down Expand Up @@ -63,9 +66,11 @@ namespace jiminy
pinocchio::Motion frameDrift_{};
};

#ifdef EXPORT_SYMBOLS
template<>
const std::string JIMINY_TEMPLATE_STATIC_MEMBER_DLLAPI
const std::string JIMINY_TEMPLATE_SPECIALIZATION_DLLEXPORT
AbstractConstraintTpl<FrameConstraint>::type_;
#endif
}

#endif // end of JIMINY_ABSTRACT_MOTOR_H
7 changes: 6 additions & 1 deletion core/include/jiminy/core/constraints/joint_constraint.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ namespace jiminy
{
class Model;

class JointConstraint;
template class JIMINY_TEMPLATE_INSTANTIATION_DLLAPI AbstractConstraintTpl<JointConstraint>;

class JIMINY_DLLAPI JointConstraint : public AbstractConstraintTpl<JointConstraint>
{
public:
Expand Down Expand Up @@ -49,9 +52,11 @@ namespace jiminy
bool isReversed_{false};
};

#ifdef EXPORT_SYMBOLS
template<>
const std::string JIMINY_TEMPLATE_STATIC_MEMBER_DLLAPI
const std::string JIMINY_TEMPLATE_SPECIALIZATION_DLLEXPORT
AbstractConstraintTpl<JointConstraint>::type_;
#endif
}

#endif // end of JIMINY_JOINT_CONSTRAINT_H
7 changes: 6 additions & 1 deletion core/include/jiminy/core/constraints/sphere_constraint.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ namespace jiminy
{
class Model;

class SphereConstraint;
template class JIMINY_TEMPLATE_INSTANTIATION_DLLAPI AbstractConstraintTpl<SphereConstraint>;

/// \brief Class constraining a sphere to roll without slipping on a flat plane.
///
/// \details Given a frame to represent the sphere center, this class constrains it to move
Expand Down Expand Up @@ -61,9 +64,11 @@ namespace jiminy
Matrix6Xd frameJacobian_{};
};

#ifdef EXPORT_SYMBOLS
template<>
const std::string JIMINY_TEMPLATE_STATIC_MEMBER_DLLAPI
const std::string JIMINY_TEMPLATE_SPECIALIZATION_DLLEXPORT
AbstractConstraintTpl<SphereConstraint>::type_;
#endif
}

#endif // end of JIMINY_SPHERE_CONSTRAINT_H
7 changes: 6 additions & 1 deletion core/include/jiminy/core/constraints/wheel_constraint.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ namespace jiminy
{
class Model;

class WheelConstraint;
template class JIMINY_TEMPLATE_INSTANTIATION_DLLAPI AbstractConstraintTpl<WheelConstraint>;

/// \brief Class constraining a wheel to roll without slipping on a flat plane.
///
/// \details Given a frame to represent the wheel center, this class constrains it to move
Expand Down Expand Up @@ -67,9 +70,11 @@ namespace jiminy
Matrix6Xd frameJacobian_{};
};

#ifdef EXPORT_SYMBOLS
template<>
const std::string JIMINY_TEMPLATE_STATIC_MEMBER_DLLAPI
const std::string JIMINY_TEMPLATE_SPECIALIZATION_DLLEXPORT
AbstractConstraintTpl<WheelConstraint>::type_;
#endif
}

#endif // end of JIMINY_WHEEL_CONSTRAINT_H
6 changes: 3 additions & 3 deletions core/include/jiminy/core/hardware/abstract_sensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -358,9 +358,9 @@ namespace jiminy
public:
/* Be careful, the static variables must be const since the 'static' keyword binds all the
sensors together, even if they are associated to complete separated robots. */
static const std::string JIMINY_TEMPLATE_STATIC_MEMBER_DLLAPI type_;
static const std::vector<std::string> JIMINY_TEMPLATE_STATIC_MEMBER_DLLAPI fieldnames_;
static const bool JIMINY_TEMPLATE_STATIC_MEMBER_DLLAPI areFieldnamesGrouped_;
static const std::string type_;
static const std::vector<std::string> fieldnames_;
static const bool areFieldnamesGrouped_;

protected:
std::size_t sensorIndex_{0};
Expand Down
59 changes: 44 additions & 15 deletions core/include/jiminy/core/hardware/basic_sensors.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ namespace jiminy
{
class Robot;

class ImuSensor;
template class JIMINY_TEMPLATE_INSTANTIATION_DLLAPI AbstractSensorTpl<ImuSensor>;

class JIMINY_DLLAPI ImuSensor final : public AbstractSensorTpl<ImuSensor>
{
public:
Expand Down Expand Up @@ -41,14 +44,19 @@ namespace jiminy
Eigen::Matrix3d sensorRotationBiasInv_{Eigen::Matrix3d::Identity()};
};

#ifdef EXPORT_SYMBOLS
template<>
const std::string JIMINY_TEMPLATE_STATIC_MEMBER_DLLAPI AbstractSensorTpl<ImuSensor>::type_;
const std::string JIMINY_TEMPLATE_SPECIALIZATION_DLLEXPORT AbstractSensorTpl<ImuSensor>::type_;
template<>
const std::vector<std::string> JIMINY_TEMPLATE_STATIC_MEMBER_DLLAPI
const std::vector<std::string> JIMINY_TEMPLATE_SPECIALIZATION_DLLEXPORT
AbstractSensorTpl<ImuSensor>::fieldnames_;
template<>
const bool JIMINY_TEMPLATE_STATIC_MEMBER_DLLAPI
const bool JIMINY_TEMPLATE_SPECIALIZATION_DLLEXPORT
AbstractSensorTpl<ImuSensor>::areFieldnamesGrouped_;
#endif

class ContactSensor;
template class JIMINY_TEMPLATE_INSTANTIATION_DLLAPI AbstractSensorTpl<ContactSensor>;

class JIMINY_DLLAPI ContactSensor final : public AbstractSensorTpl<ContactSensor>
{
Expand Down Expand Up @@ -79,14 +87,20 @@ namespace jiminy
std::size_t contactIndex_{0};
};

#ifdef EXPORT_SYMBOLS
template<>
const std::string JIMINY_TEMPLATE_STATIC_MEMBER_DLLAPI AbstractSensorTpl<ContactSensor>::type_;
const std::string JIMINY_TEMPLATE_SPECIALIZATION_DLLEXPORT
AbstractSensorTpl<ContactSensor>::type_;
template<>
const std::vector<std::string> JIMINY_TEMPLATE_STATIC_MEMBER_DLLAPI
const std::vector<std::string> JIMINY_TEMPLATE_SPECIALIZATION_DLLEXPORT
AbstractSensorTpl<ContactSensor>::fieldnames_;
template<>
const bool JIMINY_TEMPLATE_STATIC_MEMBER_DLLAPI
const bool JIMINY_TEMPLATE_SPECIALIZATION_DLLEXPORT
AbstractSensorTpl<ContactSensor>::areFieldnamesGrouped_;
#endif

class ForceSensor;
template class JIMINY_TEMPLATE_INSTANTIATION_DLLAPI AbstractSensorTpl<ForceSensor>;

class JIMINY_DLLAPI ForceSensor final : public AbstractSensorTpl<ForceSensor>
{
Expand Down Expand Up @@ -120,14 +134,20 @@ namespace jiminy
pinocchio::Force f_{};
};

#ifdef EXPORT_SYMBOLS
template<>
const std::string JIMINY_TEMPLATE_STATIC_MEMBER_DLLAPI AbstractSensorTpl<ForceSensor>::type_;
const std::string JIMINY_TEMPLATE_SPECIALIZATION_DLLEXPORT
AbstractSensorTpl<ForceSensor>::type_;
template<>
const std::vector<std::string> JIMINY_TEMPLATE_STATIC_MEMBER_DLLAPI
const std::vector<std::string> JIMINY_TEMPLATE_SPECIALIZATION_DLLEXPORT
AbstractSensorTpl<ForceSensor>::fieldnames_;
template<>
const bool JIMINY_TEMPLATE_STATIC_MEMBER_DLLAPI
const bool JIMINY_TEMPLATE_SPECIALIZATION_DLLEXPORT
AbstractSensorTpl<ForceSensor>::areFieldnamesGrouped_;
#endif

class EncoderSensor;
template class JIMINY_TEMPLATE_INSTANTIATION_DLLAPI AbstractSensorTpl<EncoderSensor>;

class JIMINY_DLLAPI EncoderSensor final : public AbstractSensorTpl<EncoderSensor>
{
Expand Down Expand Up @@ -159,14 +179,20 @@ namespace jiminy
JointModelType jointType_{JointModelType::UNSUPPORTED};
};

#ifdef EXPORT_SYMBOLS
template<>
const std::string JIMINY_TEMPLATE_STATIC_MEMBER_DLLAPI AbstractSensorTpl<EncoderSensor>::type_;
const std::string JIMINY_TEMPLATE_SPECIALIZATION_DLLEXPORT
AbstractSensorTpl<EncoderSensor>::type_;
template<>
const std::vector<std::string> JIMINY_TEMPLATE_STATIC_MEMBER_DLLAPI
const std::vector<std::string> JIMINY_TEMPLATE_SPECIALIZATION_DLLEXPORT
AbstractSensorTpl<EncoderSensor>::fieldnames_;
template<>
const bool JIMINY_TEMPLATE_STATIC_MEMBER_DLLAPI
const bool JIMINY_TEMPLATE_SPECIALIZATION_DLLEXPORT
AbstractSensorTpl<EncoderSensor>::areFieldnamesGrouped_;
#endif

class EffortSensor;
template class JIMINY_TEMPLATE_INSTANTIATION_DLLAPI AbstractSensorTpl<EffortSensor>;

class JIMINY_DLLAPI EffortSensor final : public AbstractSensorTpl<EffortSensor>
{
Expand Down Expand Up @@ -196,14 +222,17 @@ namespace jiminy
std::size_t motorIndex_{0};
};

#ifdef EXPORT_SYMBOLS
template<>
const std::string JIMINY_TEMPLATE_STATIC_MEMBER_DLLAPI AbstractSensorTpl<EffortSensor>::type_;
const std::string JIMINY_TEMPLATE_SPECIALIZATION_DLLEXPORT
AbstractSensorTpl<EffortSensor>::type_;
template<>
const std::vector<std::string> JIMINY_TEMPLATE_STATIC_MEMBER_DLLAPI
const std::vector<std::string> JIMINY_TEMPLATE_SPECIALIZATION_DLLEXPORT
AbstractSensorTpl<EffortSensor>::fieldnames_;
template<>
const bool JIMINY_TEMPLATE_STATIC_MEMBER_DLLAPI
const bool JIMINY_TEMPLATE_SPECIALIZATION_DLLEXPORT
AbstractSensorTpl<EffortSensor>::areFieldnamesGrouped_;
#endif
}

#endif // end of JIMINY_BASIC_SENSORS_H
18 changes: 8 additions & 10 deletions core/include/jiminy/core/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,31 +24,29 @@
# define JIMINY_DLLEXPORT __declspec(dllexport)
# define JIMINY_TEMPLATE_DLLIMPORT
# define JIMINY_TEMPLATE_DLLEXPORT
# define JIMINY_TEMPLATE_STATIC_MEMBER_DLLIMPORT JIMINY_DLLIMPORT
# define JIMINY_TEMPLATE_STATIC_MEMBER_DLLEXPORT JIMINY_DLLEXPORT
# define JIMINY_TEMPLATE_EXPLICIT_INSTANTIATION_DLLIMPORT JIMINY_DLLIMPORT
# define JIMINY_TEMPLATE_EXPLICIT_INSTANTIATION_DLLEXPORT JIMINY_DLLEXPORT
# define JIMINY_TEMPLATE_SPECIALIZATION_DLLEXPORT JIMINY_DLLEXPORT
# define JIMINY_TEMPLATE_INSTANTIATION_DLLIMPORT JIMINY_DLLIMPORT
# define JIMINY_TEMPLATE_INSTANTIATION_DLLEXPORT JIMINY_DLLEXPORT
#else
// On Linux, tag symbols using de-facto standard visibility attribute extension
# define JIMINY_DLLIMPORT __attribute__((visibility("default")))
# define JIMINY_DLLEXPORT __attribute__((visibility("default")))
# define JIMINY_TEMPLATE_DLLIMPORT JIMINY_DLLIMPORT
# define JIMINY_TEMPLATE_DLLEXPORT JIMINY_DLLEXPORT
# define JIMINY_TEMPLATE_STATIC_MEMBER_DLLIMPORT
# define JIMINY_TEMPLATE_STATIC_MEMBER_DLLEXPORT
# define JIMINY_TEMPLATE_EXPLICIT_INSTANTIATION_DLLIMPORT
# define JIMINY_TEMPLATE_EXPLICIT_INSTANTIATION_DLLEXPORT
# define JIMINY_TEMPLATE_SPECIALIZATION_DLLEXPORT
# define JIMINY_TEMPLATE_INSTANTIATION_DLLIMPORT
# define JIMINY_TEMPLATE_INSTANTIATION_DLLEXPORT
#endif

// Define DLLAPI to import or export depending on whether one is building or using the library
#ifdef EXPORT_SYMBOLS
# define JIMINY_DLLAPI JIMINY_DLLEXPORT
# define JIMINY_TEMPLATE_DLLAPI JIMINY_TEMPLATE_DLLEXPORT
# define JIMINY_TEMPLATE_STATIC_MEMBER_DLLAPI JIMINY_TEMPLATE_STATIC_MEMBER_DLLEXPORT
# define JIMINY_TEMPLATE_INSTANTIATION_DLLAPI JIMINY_TEMPLATE_INSTANTIATION_DLLEXPORT
#else
# define JIMINY_DLLAPI JIMINY_DLLIMPORT
# define JIMINY_TEMPLATE_DLLAPI JIMINY_TEMPLATE_DLLIMPORT
# define JIMINY_TEMPLATE_STATIC_MEMBER_DLLAPI JIMINY_TEMPLATE_STATIC_MEMBER_DLLIMPORT
# define JIMINY_TEMPLATE_INSTANTIATION_DLLAPI JIMINY_TEMPLATE_INSTANTIATION_DLLIMPORT
#endif

// ******************************* Error and warnings utilities ******************************** //
Expand Down

0 comments on commit a5421ef

Please sign in to comment.