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

[core] Flatten nested namespaces. #656

Merged
merged 1 commit into from
Oct 18, 2023
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
4 changes: 1 addition & 3 deletions core/include/jiminy/core/control/abstract_controller.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,4 @@ namespace jiminy
}
}

#endif // JIMINY_ABSTRACT_CONTROLLER_HXX


#endif // JIMINY_ABSTRACT_CONTROLLER_HXX
2 changes: 1 addition & 1 deletion core/include/jiminy/core/engine/engine_multi_robot.h
Original file line number Diff line number Diff line change
Expand Up @@ -675,4 +675,4 @@ namespace jiminy
};
}

#endif //end of JIMINY_ENGINE_MULTIROBOT_H
#endif // JIMINY_ENGINE_MULTIROBOT_H
2 changes: 1 addition & 1 deletion core/include/jiminy/core/io/abstract_io_device.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ namespace jiminy
template<> hresult_t AbstractIODevice::write<std::vector<uint64_t> >(std::vector<uint64_t> const & v);
}

#endif // JIMINY_ABSTRACT_IO_DEVICE_HXX
#endif // JIMINY_ABSTRACT_IO_DEVICE_HXX
3 changes: 2 additions & 1 deletion core/include/jiminy/core/io/json_loader.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,6 @@ namespace jiminy
std::vector<char_t> payload_;
std::shared_ptr<AbstractIODevice> device_;
};
} // End of namespace jiminy.
}

#endif // JIMINY_JSON_LOADER_H
51 changes: 24 additions & 27 deletions core/include/jiminy/core/io/serialization.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -42,34 +42,31 @@ namespace jiminy
}


namespace boost
namespace boost::serialization
{
namespace serialization
{
template<class Archive>
void load_construct_data(Archive & /* ar */,
pinocchio::GeometryObject * geomPtr,
unsigned int const /* version */)
{
::new(geomPtr) pinocchio::GeometryObject(
"", 0, 0, {nullptr}, pinocchio::SE3::Identity());
}
template<class Archive>
void load_construct_data(Archive & /* ar */,
pinocchio::GeometryObject * geomPtr,
unsigned int const /* version */)
{
::new(geomPtr) pinocchio::GeometryObject(
"", 0, 0, {nullptr}, pinocchio::SE3::Identity());
}

template<class Archive>
void serialize(Archive & ar,
pinocchio::GeometryObject & geom,
unsigned int const /* version */);
template<class Archive>
void serialize(Archive & ar,
pinocchio::GeometryObject & geom,
unsigned int const /* version */);

template <class Archive>
void serialize(Archive & ar,
pinocchio::GeometryModel & model,
unsigned int const /* version */)
{
ar & make_nvp("ngeoms", model.ngeoms);
ar & make_nvp("geometryObjects", model.geometryObjects);
ar & make_nvp("collisionPairs", model.collisionPairs);
}
} // namespace serialization
} // namespace boost
template <class Archive>
void serialize(Archive & ar,
pinocchio::GeometryModel & model,
unsigned int const /* version */)
{
ar & make_nvp("ngeoms", model.ngeoms);
ar & make_nvp("geometryObjects", model.geometryObjects);
ar & make_nvp("collisionPairs", model.collisionPairs);
}
}

#endif // JIMINY_SERIALIZATION_HXX
#endif // JIMINY_SERIALIZATION_HXX
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@
#include "jiminy/core/engine/engine_multi_robot.h"


namespace jiminy
{
namespace pinocchio_overload
namespace jiminy::pinocchio_overload
{
template<typename Scalar, int Options, template<typename, int> class JointCollectionTpl,
typename ConfigVectorType, typename TangentVectorType>
Expand Down Expand Up @@ -546,6 +544,5 @@ namespace pinocchio_overload
return data.llt_JMinvJt.solve(v);
}
}
}

#endif //end of JIMINY_ALGORITHMS_MOTOR_INERTIA_H
#endif // JIMINY_ALGORITHMS_MOTOR_INERTIA_H
2 changes: 1 addition & 1 deletion core/include/jiminy/core/stepper/lie_group.h
Original file line number Diff line number Diff line change
Expand Up @@ -1319,4 +1319,4 @@ namespace jiminy
using stateDerivative_t = Eigen::StateDerivativeVector;
}

#endif //end of JIMINY_LIE_GROUP_H
#endif // JIMINY_LIE_GROUP_H
4 changes: 2 additions & 2 deletions core/include/jiminy/core/telemetry/telemetry_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ namespace jiminy
std::deque<std::pair<std::string, float64_t> > floatsRegistry_; ///< Memory to handle floats
bool_t isRegisteringAvailable_; ///< Whether registering is available
};
} // namespace jiminy
}

#include "jiminy/core/telemetry/telemetry_data.hxx"

#endif // JIMINY_TELEMETRY_DATA_H
#endif // JIMINY_TELEMETRY_DATA_H
4 changes: 2 additions & 2 deletions core/include/jiminy/core/telemetry/telemetry_data.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ namespace jiminy

return hresult_t::SUCCESS;
}
} // namespace jiminy
}

#endif // JIMINY_TELEMETRY_DATA_HXX
#endif // JIMINY_TELEMETRY_DATA_HXX
4 changes: 2 additions & 2 deletions core/include/jiminy/core/telemetry/telemetry_sender.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ namespace jiminy
/// reserved position in the contiguous storage of telemetry data.
telemetry_data_registry_t<float64_t, int64_t> bufferPosition_;
};
} // End of jiminy namespace
}

#include "jiminy/core/telemetry/telemetry_sender.hxx"

#endif // JIMINY_TELEMETRY_CLIENT_CLASS_H
#endif // JIMINY_TELEMETRY_CLIENT_CLASS_H
4 changes: 2 additions & 2 deletions core/include/jiminy/core/telemetry/telemetry_sender.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ namespace jiminy
}
return returnCode;
}
} // namespace jiminy
}

#endif // JIMINY_TELEMETRY_SENDER_HXX
#endif // JIMINY_TELEMETRY_SENDER_HXX
7 changes: 2 additions & 5 deletions core/include/jiminy/core/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,9 @@


// `pinocchio::container::aligned_vector`
namespace pinocchio
namespace pinocchio::container
{
namespace container
{
template<typename T> struct aligned_vector;
}
template<typename T> struct aligned_vector;
}


Expand Down
2 changes: 1 addition & 1 deletion core/src/io/json_loader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ namespace jiminy
{
return rootJson_.get();
}
} // End of namespace jiminy.
}
131 changes: 64 additions & 67 deletions core/src/io/serialization.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,79 +17,76 @@
EXPL_TPL_INST_SERIALIZE_IMPL(boost::archive::binary_oarchive, __VA_ARGS__)


namespace boost
namespace boost::serialization
{
namespace serialization
template<class Archive>
void serialize(Archive & ar,
pinocchio::GeometryObject & geom,
const unsigned int /* version */)
{
template<class Archive>
void serialize(Archive & ar,
pinocchio::GeometryObject & geom,
const unsigned int /* version */)
{
ar & make_nvp("name", geom.name);
ar & make_nvp("parentFrame", geom.parentFrame);
ar & make_nvp("parentJoint", geom.parentJoint);

/* Manual polymorphic up-casting to avoid relying on boost
serialization for doing it, otherwise it would conflict
with any pinocchio bindings exposing the same objects. */
hpp::fcl::NODE_TYPE nodeType;
if (Archive::is_saving::value)
{
nodeType = geom.geometry->getNodeType();
}
ar & make_nvp("nodeType", nodeType);
ar & make_nvp("name", geom.name);
ar & make_nvp("parentFrame", geom.parentFrame);
ar & make_nvp("parentJoint", geom.parentJoint);

#define UPCAST_FROM_TYPENAME(TYPENAME, CLASS) \
case hpp::fcl::NODE_TYPE::TYPENAME: \
if (Archive::is_loading::value) \
{ \
geom.geometry = std::shared_ptr<CLASS>(new CLASS); \
} \
ar & make_nvp("geometry", static_cast<CLASS &>(*geom.geometry)); \
break;

switch (nodeType)
{
UPCAST_FROM_TYPENAME(GEOM_TRIANGLE, hpp::fcl::TriangleP)
UPCAST_FROM_TYPENAME(GEOM_SPHERE, hpp::fcl::Sphere)
UPCAST_FROM_TYPENAME(GEOM_BOX, hpp::fcl::Box)
UPCAST_FROM_TYPENAME(GEOM_CAPSULE, hpp::fcl::Capsule)
UPCAST_FROM_TYPENAME(GEOM_CONE, hpp::fcl::Cone)
UPCAST_FROM_TYPENAME(GEOM_CYLINDER, hpp::fcl::Cylinder)
UPCAST_FROM_TYPENAME(GEOM_HALFSPACE, hpp::fcl::Halfspace)
UPCAST_FROM_TYPENAME(GEOM_PLANE, hpp::fcl::Plane)
UPCAST_FROM_TYPENAME(GEOM_ELLIPSOID, hpp::fcl::Ellipsoid)
UPCAST_FROM_TYPENAME(GEOM_CONVEX, hpp::fcl::Convex<hpp::fcl::Triangle>)
UPCAST_FROM_TYPENAME(BV_AABB, hpp::fcl::BVHModel<hpp::fcl::AABB>)
UPCAST_FROM_TYPENAME(BV_OBB, hpp::fcl::BVHModel<hpp::fcl::OBB>)
UPCAST_FROM_TYPENAME(BV_RSS, hpp::fcl::BVHModel<hpp::fcl::RSS>)
UPCAST_FROM_TYPENAME(BV_OBBRSS, hpp::fcl::BVHModel<hpp::fcl::OBBRSS>)
UPCAST_FROM_TYPENAME(BV_kIOS, hpp::fcl::BVHModel<hpp::fcl::kIOS>)
UPCAST_FROM_TYPENAME(BV_KDOP16, hpp::fcl::BVHModel<hpp::fcl::KDOP<16> >)
UPCAST_FROM_TYPENAME(BV_KDOP18, hpp::fcl::BVHModel<hpp::fcl::KDOP<18> >)
UPCAST_FROM_TYPENAME(BV_KDOP24, hpp::fcl::BVHModel<hpp::fcl::KDOP<24> >)
case hpp::fcl::NODE_TYPE::GEOM_OCTREE:
case hpp::fcl::NODE_TYPE::HF_AABB:
case hpp::fcl::NODE_TYPE::HF_OBBRSS:
case hpp::fcl::NODE_TYPE::BV_UNKNOWN:
case hpp::fcl::NODE_TYPE::NODE_COUNT:
default:
// Falling back to polymorphism
ar & make_nvp("geometry", geom.geometry);
break;
}
/* Manual polymorphic up-casting to avoid relying on boost
serialization for doing it, otherwise it would conflict
with any pinocchio bindings exposing the same objects. */
hpp::fcl::NODE_TYPE nodeType;
if (Archive::is_saving::value)
{
nodeType = geom.geometry->getNodeType();
}
ar & make_nvp("nodeType", nodeType);

#undef UPCAST_FROM_TYPENAME
#define UPCAST_FROM_TYPENAME(TYPENAME, CLASS) \
case hpp::fcl::NODE_TYPE::TYPENAME: \
if (Archive::is_loading::value) \
{ \
geom.geometry = std::shared_ptr<CLASS>(new CLASS); \
} \
ar & make_nvp("geometry", static_cast<CLASS &>(*geom.geometry)); \
break;

ar & make_nvp("placement", geom.placement);
ar & make_nvp("meshPath", geom.meshPath);
ar & make_nvp("meshScale", geom.meshScale);
ar & make_nvp("overrideMaterial", geom.overrideMaterial);
ar & make_nvp("meshColor", geom.meshColor);
ar & make_nvp("meshTexturePath", geom.meshTexturePath);
switch (nodeType)
{
UPCAST_FROM_TYPENAME(GEOM_TRIANGLE, hpp::fcl::TriangleP)
UPCAST_FROM_TYPENAME(GEOM_SPHERE, hpp::fcl::Sphere)
UPCAST_FROM_TYPENAME(GEOM_BOX, hpp::fcl::Box)
UPCAST_FROM_TYPENAME(GEOM_CAPSULE, hpp::fcl::Capsule)
UPCAST_FROM_TYPENAME(GEOM_CONE, hpp::fcl::Cone)
UPCAST_FROM_TYPENAME(GEOM_CYLINDER, hpp::fcl::Cylinder)
UPCAST_FROM_TYPENAME(GEOM_HALFSPACE, hpp::fcl::Halfspace)
UPCAST_FROM_TYPENAME(GEOM_PLANE, hpp::fcl::Plane)
UPCAST_FROM_TYPENAME(GEOM_ELLIPSOID, hpp::fcl::Ellipsoid)
UPCAST_FROM_TYPENAME(GEOM_CONVEX, hpp::fcl::Convex<hpp::fcl::Triangle>)
UPCAST_FROM_TYPENAME(BV_AABB, hpp::fcl::BVHModel<hpp::fcl::AABB>)
UPCAST_FROM_TYPENAME(BV_OBB, hpp::fcl::BVHModel<hpp::fcl::OBB>)
UPCAST_FROM_TYPENAME(BV_RSS, hpp::fcl::BVHModel<hpp::fcl::RSS>)
UPCAST_FROM_TYPENAME(BV_OBBRSS, hpp::fcl::BVHModel<hpp::fcl::OBBRSS>)
UPCAST_FROM_TYPENAME(BV_kIOS, hpp::fcl::BVHModel<hpp::fcl::kIOS>)
UPCAST_FROM_TYPENAME(BV_KDOP16, hpp::fcl::BVHModel<hpp::fcl::KDOP<16> >)
UPCAST_FROM_TYPENAME(BV_KDOP18, hpp::fcl::BVHModel<hpp::fcl::KDOP<18> >)
UPCAST_FROM_TYPENAME(BV_KDOP24, hpp::fcl::BVHModel<hpp::fcl::KDOP<24> >)
case hpp::fcl::NODE_TYPE::GEOM_OCTREE:
case hpp::fcl::NODE_TYPE::HF_AABB:
case hpp::fcl::NODE_TYPE::HF_OBBRSS:
case hpp::fcl::NODE_TYPE::BV_UNKNOWN:
case hpp::fcl::NODE_TYPE::NODE_COUNT:
default:
// Falling back to polymorphism
ar & make_nvp("geometry", geom.geometry);
break;
}

EXPLICIT_TEMPLATE_INSTANTIATION_SERIALIZE(pinocchio::GeometryObject)
#undef UPCAST_FROM_TYPENAME

ar & make_nvp("placement", geom.placement);
ar & make_nvp("meshPath", geom.meshPath);
ar & make_nvp("meshScale", geom.meshScale);
ar & make_nvp("overrideMaterial", geom.overrideMaterial);
ar & make_nvp("meshColor", geom.meshColor);
ar & make_nvp("meshTexturePath", geom.meshTexturePath);
}

EXPLICIT_TEMPLATE_INSTANTIATION_SERIALIZE(pinocchio::GeometryObject)
}
2 changes: 1 addition & 1 deletion core/src/telemetry/telemetry_data.cc
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,4 @@ namespace jiminy
{
return &floatsRegistry_;
}
}// end of namespace jiminy
}
2 changes: 1 addition & 1 deletion core/src/telemetry/telemetry_sender.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ namespace jiminy
{
return objectName_;
}
} // End of namespace jiminy.
}
7 changes: 2 additions & 5 deletions python/jiminy_pywrap/include/jiminy/python/compatibility.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@
#define COMPATIBILITY_PYTHON_H


namespace jiminy
{
namespace python
namespace jiminy::python
{
void exposeCompatibility(void);
} // End of namespace python.
} // End of namespace jiminy.
}

#endif // COMPATIBILITY_PYTHON_H
7 changes: 2 additions & 5 deletions python/jiminy_pywrap/include/jiminy/python/constraints.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@
#define CONSTRAINTS_PYTHON_H


namespace jiminy
{
namespace python
namespace jiminy::python
{
void exposeConstraint(void);
void exposeConstraintsHolder(void);
} // End of namespace python.
} // End of namespace jiminy.
}

#endif // CONSTRAINTS_PYTHON_H
7 changes: 2 additions & 5 deletions python/jiminy_pywrap/include/jiminy/python/controllers.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@
#define CONTROLLERS_PYTHON_H


namespace jiminy
{
namespace python
namespace jiminy::python
{
void exposeAbstractController(void);
void exposeControllerFunctor(void);
} // End of namespace python.
} // End of namespace jiminy.
}

#endif // CONTROLLERS_PYTHON_H
7 changes: 2 additions & 5 deletions python/jiminy_pywrap/include/jiminy/python/engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,14 @@
#define SIMULATOR_PYTHON_H


namespace jiminy
{
namespace python
namespace jiminy::python
{
void exposeForces(void);
void exposeStepperState(void);
void exposeSystemState(void);
void exposeSystem(void);
void exposeEngineMultiRobot(void);
void exposeEngine(void);
} // End of namespace python.
} // End of namespace jiminy.
}

#endif // SIMULATOR_PYTHON_H
Loading