Convert mjElement to struct rather than opaque pointer.

By making mjElement the parent of mjCBase, mjCModel, and mjCDef, this CL enables safer casting using static_cast instead of reinterpret_cast and C-style casting.

PiperOrigin-RevId: 619526291
Change-Id: Ifa2b4bd3ecd95bade61f41a7005c62212f456c00
This commit is contained in:
Alessio Quaglino
2024-03-27 07:36:43 -07:00
committed by Copybara-Service
parent e6bf6fc327
commit dfe2b75378
10 changed files with 199 additions and 163 deletions
+2 -2
View File
@@ -167,7 +167,7 @@ class mjCBoundingVolumeHierarchy : public mjCBoundingVolumeHierarchy_ {
//------------------------- class mjCBase ----------------------------------------------------------
// Generic functionality for all derived classes
class mjCBase_ {
class mjCBase_ : public mjElement {
public:
int id; // object id
std::string name; // object name
@@ -1606,7 +1606,7 @@ class mjCKey : public mjCKey_, private mjsKey {
//------------------------- class mjCDef -----------------------------------------------------------
// Describes one set of defaults
class mjCDef {
class mjCDef : public mjElement {
friend class mjXWriter;
public: