diff --git a/include/sdf/Actor.hh b/include/sdf/Actor.hh index 509ae58a9..57c5c0fc9 100644 --- a/include/sdf/Actor.hh +++ b/include/sdf/Actor.hh @@ -193,6 +193,9 @@ namespace sdf /// \brief Default constructor public: Actor(); + /// \brief Get the schema file name accessor + public: static inline std::string_view SchemaFile(); + /// \brief Load the actor based on a element pointer. This is *not* the /// usual entry point. Typical usage of the SDF DOM is through the Root /// object. diff --git a/include/sdf/AirPressure.hh b/include/sdf/AirPressure.hh index 798474dd5..b8fae845e 100644 --- a/include/sdf/AirPressure.hh +++ b/include/sdf/AirPressure.hh @@ -36,6 +36,9 @@ namespace sdf /// \brief Default constructor public: AirPressure(); + /// \brief Get the schema file name accessor + public: static inline std::string_view SchemaFile(); + /// \brief Load the airPressure based on an element pointer. /// This is *not* the usual entry point. Typical usage of the SDF DOM is /// through the Root object. diff --git a/include/sdf/AirSpeed.hh b/include/sdf/AirSpeed.hh index 90a1be025..050c7fac6 100644 --- a/include/sdf/AirSpeed.hh +++ b/include/sdf/AirSpeed.hh @@ -36,6 +36,9 @@ namespace sdf /// \brief Default constructor public: AirSpeed(); + /// \brief Get the schema file name accessor + public: static inline std::string_view SchemaFile(); + /// \brief Load the air speed based on an element pointer. /// This is *not* the usual entry point. Typical usage of the SDF DOM is /// through the Root object. diff --git a/include/sdf/Altimeter.hh b/include/sdf/Altimeter.hh index c27a6daf1..d6ac7a962 100644 --- a/include/sdf/Altimeter.hh +++ b/include/sdf/Altimeter.hh @@ -35,6 +35,9 @@ namespace sdf /// \brief Default constructor public: Altimeter(); + /// \brief Get the schema file name accessor + public: static inline std::string_view SchemaFile(); + /// \brief Load the altimeter based on an element pointer. This is *not* /// the usual entry point. Typical usage of the SDF DOM is through the Root /// object. diff --git a/include/sdf/Atmosphere.hh b/include/sdf/Atmosphere.hh index ed4042128..3efb86813 100644 --- a/include/sdf/Atmosphere.hh +++ b/include/sdf/Atmosphere.hh @@ -47,6 +47,9 @@ namespace sdf /// \brief Default constructor public: Atmosphere(); + /// \brief Get the schema file name accessor + public: static inline std::string_view SchemaFile(); + /// \brief Load the atmosphere based on a element pointer. This is *not* the /// usual entry point. Typical usage of the SDF DOM is through the Root /// object. diff --git a/include/sdf/Camera.hh b/include/sdf/Camera.hh index 5c46827c8..6b25af210 100644 --- a/include/sdf/Camera.hh +++ b/include/sdf/Camera.hh @@ -62,6 +62,9 @@ namespace sdf /// \brief Constructor public: Camera(); + /// \brief Get the schema file name accessor + public: static inline std::string_view SchemaFile(); + /// \brief Return true if both Camera objects contain the same values. /// \param[_in] _alt Camera value to compare. /// \returen True if 'this' == _alt. diff --git a/include/sdf/Collision.hh b/include/sdf/Collision.hh index 2ab4114ce..f49700f59 100644 --- a/include/sdf/Collision.hh +++ b/include/sdf/Collision.hh @@ -52,6 +52,9 @@ namespace sdf /// \brief Default constructor public: Collision(); + /// \brief Get the schema file name accessor + public: static inline std::string_view SchemaFile(); + /// \brief Load the collision based on a element pointer. This is *not* the /// usual entry point. Typical usage of the SDF DOM is through the Root /// object. diff --git a/include/sdf/ForceTorque.hh b/include/sdf/ForceTorque.hh index 2a9a693ed..c84cd693f 100644 --- a/include/sdf/ForceTorque.hh +++ b/include/sdf/ForceTorque.hh @@ -66,6 +66,8 @@ namespace sdf /// \brief Default constructor public: ForceTorque(); + public: static inline std::string_view SchemaFile(); + /// \brief Load the force torque sensor based on an element pointer. This is /// *not* the usual entry point. Typical usage of the SDF DOM is through the /// Root object. diff --git a/include/sdf/Frame.hh b/include/sdf/Frame.hh index cecb63ea9..90e9d0d45 100644 --- a/include/sdf/Frame.hh +++ b/include/sdf/Frame.hh @@ -44,6 +44,9 @@ namespace sdf /// \brief Default constructor public: Frame(); + /// \brief Get the schema file name accessor + public: static inline std::string_view SchemaFile(); + /// \brief Load the frame based on a element pointer. This is *not* the /// usual entry point. Typical usage of the SDF DOM is through the Root /// object. diff --git a/include/sdf/Geometry.hh b/include/sdf/Geometry.hh index 35fd1e1cd..800dfb9a6 100644 --- a/include/sdf/Geometry.hh +++ b/include/sdf/Geometry.hh @@ -90,6 +90,9 @@ namespace sdf /// \brief Default constructor public: Geometry(); + /// \brief Get the schema file name accessor + public: static inline std::string_view SchemaFile(); + /// \brief Load the geometry based on a element pointer. This is *not* the /// usual entry point. Typical usage of the SDF DOM is through the Root /// object. diff --git a/include/sdf/Gui.hh b/include/sdf/Gui.hh index 67435fdb0..a66ab4d41 100644 --- a/include/sdf/Gui.hh +++ b/include/sdf/Gui.hh @@ -33,6 +33,9 @@ namespace sdf /// \brief Default constructor public: Gui(); + /// \brief Get the schema file name accessor + public: static inline std::string_view SchemaFile(); + /// \brief Load the gui based on a element pointer. This is *not* the /// usual entry point. Typical usage of the SDF DOM is through the Root /// object. diff --git a/include/sdf/Imu.hh b/include/sdf/Imu.hh index e3ced1181..83ce17a40 100644 --- a/include/sdf/Imu.hh +++ b/include/sdf/Imu.hh @@ -35,6 +35,9 @@ namespace sdf /// \brief Default constructor public: Imu(); + /// \brief Get the schema file name accessor + public: static inline std::string_view SchemaFile(); + /// \brief Load the IMU based on an element pointer. This is *not* /// the usual entry point. Typical usage of the SDF DOM is through the Root /// object. diff --git a/include/sdf/Joint.hh b/include/sdf/Joint.hh index 26c4b226f..1147ad4e2 100644 --- a/include/sdf/Joint.hh +++ b/include/sdf/Joint.hh @@ -87,6 +87,9 @@ namespace sdf /// \brief Default constructor public: Joint(); + /// \brief Get the schema file name accessor + public: static inline std::string_view SchemaFile(); + /// \brief Load the joint based on a element pointer. This is *not* the /// usual entry point. Typical usage of the SDF DOM is through the Root /// object. diff --git a/include/sdf/Lidar.hh b/include/sdf/Lidar.hh index 89cfa612b..dac6bb4ab 100644 --- a/include/sdf/Lidar.hh +++ b/include/sdf/Lidar.hh @@ -107,6 +107,9 @@ namespace sdf /// \brief Default constructor public: Lidar(); + /// \brief Get the schema file name accessor + public: static inline std::string_view SchemaFile(); + /// \brief Load the lidar based on an element pointer. This is *not* /// the usual entry point. Typical usage of the SDF DOM is through the Root /// object. diff --git a/include/sdf/Light.hh b/include/sdf/Light.hh index fc19e02f1..21f31e763 100644 --- a/include/sdf/Light.hh +++ b/include/sdf/Light.hh @@ -65,6 +65,9 @@ namespace sdf /// \brief Default constructor public: Light(); + /// \brief Get the schema file name accessor + public: static inline std::string_view SchemaFile(); + /// \brief Load the light based on a element pointer. This is *not* the /// usual entry point. Typical usage of the SDF DOM is through the Root /// object. diff --git a/include/sdf/Link.hh b/include/sdf/Link.hh index 3e5260e73..291fa27b0 100644 --- a/include/sdf/Link.hh +++ b/include/sdf/Link.hh @@ -53,6 +53,9 @@ namespace sdf /// \brief Default constructor public: Link(); + /// \brief Get the schema file name accessor + public: static inline std::string_view SchemaFile(); + /// \brief Load the link based on a element pointer. This is *not* the /// usual entry point. Typical usage of the SDF DOM is through the Root /// object. diff --git a/include/sdf/Magnetometer.hh b/include/sdf/Magnetometer.hh index 3f6d9ae74..db1d4f697 100644 --- a/include/sdf/Magnetometer.hh +++ b/include/sdf/Magnetometer.hh @@ -36,6 +36,9 @@ namespace sdf /// \brief Default constructor public: Magnetometer(); + /// \brief Get the schema file name accessor + public: static inline std::string_view SchemaFile(); + /// \brief Load the magnetometer based on an element pointer. This is *not* /// the usual entry point. Typical usage of the SDF DOM is through the Root /// object. diff --git a/include/sdf/Material.hh b/include/sdf/Material.hh index 6891a8899..32115d9b6 100644 --- a/include/sdf/Material.hh +++ b/include/sdf/Material.hh @@ -48,6 +48,9 @@ namespace sdf /// \brief Default constructor public: Material(); + /// \brief Get the schema file name accessor + public: static inline std::string_view SchemaFile(); + /// \brief Load the material based on a element pointer. This is *not* the /// usual entry point. Typical usage of the SDF DOM is through the Root /// object. diff --git a/include/sdf/Model.hh b/include/sdf/Model.hh index 86cc3d422..163121965 100644 --- a/include/sdf/Model.hh +++ b/include/sdf/Model.hh @@ -56,6 +56,9 @@ namespace sdf /// \brief Default constructor public: Model(); + /// \brief Get the schema file name accessor + public: static inline std::string_view SchemaFile(); + /// \brief Load the model based on a element pointer. This is *not* the /// usual entry point. Typical usage of the SDF DOM is through the Root /// object. diff --git a/include/sdf/NavSat.hh b/include/sdf/NavSat.hh index 9b1677d77..e85b6d0f6 100644 --- a/include/sdf/NavSat.hh +++ b/include/sdf/NavSat.hh @@ -82,6 +82,9 @@ namespace sdf /// \param[in] _sdf The SDF Element pointer /// \return Errors, which is a vector of Error objects. Each Error includes /// an error code and message. An empty vector indicates no error. + + public: static inline std::string_view SchemaFile(); + public: Errors Load(ElementPtr _sdf); /// \brief Get a pointer to the SDF element that was used during diff --git a/include/sdf/Noise.hh b/include/sdf/Noise.hh index 361e12f7e..202f57efb 100644 --- a/include/sdf/Noise.hh +++ b/include/sdf/Noise.hh @@ -49,6 +49,9 @@ namespace sdf /// \brief Default constructor public: Noise(); + /// \brief Get the schema file name accessor + public: static inline std::string_view SchemaFile(); + /// \brief Return true if both Noise objects contain the same values. /// \param[_in] _noise Noise value to compare. /// \return True if 'this' == _noise. diff --git a/include/sdf/ParticleEmitter.hh b/include/sdf/ParticleEmitter.hh index bf592de24..d20534db1 100644 --- a/include/sdf/ParticleEmitter.hh +++ b/include/sdf/ParticleEmitter.hh @@ -62,6 +62,9 @@ namespace sdf /// \brief Default constructor public: ParticleEmitter(); + /// \brief Get the schema file name accessor + public: static inline std::string_view SchemaFile(); + /// \brief Load the particle emitter based on an element pointer. This is /// *not* the usual entry point. Typical usage of the SDF DOM is through /// the Root object. diff --git a/include/sdf/Physics.hh b/include/sdf/Physics.hh index 0fa5ea5ef..6bd63e54b 100644 --- a/include/sdf/Physics.hh +++ b/include/sdf/Physics.hh @@ -38,6 +38,9 @@ namespace sdf /// \brief Default constructor public: Physics(); + /// \brief Get the schema file name accessor + public: static inline std::string_view SchemaFile(); + /// \brief Load the physics based on an element pointer. This is *not* the /// usual entry point. Typical usage of the SDF DOM is through the Root /// object. diff --git a/include/sdf/Plugin.hh b/include/sdf/Plugin.hh index def211593..bc49a4f0d 100644 --- a/include/sdf/Plugin.hh +++ b/include/sdf/Plugin.hh @@ -47,6 +47,9 @@ namespace sdf /// \brief Default constructor public: Plugin(); + /// \brief Get the schema file name accessor + public: static inline std::string_view SchemaFile(); + /// \brief Default destructor public: ~Plugin(); diff --git a/include/sdf/Projector.hh b/include/sdf/Projector.hh index b13fd8797..a4c8bdd81 100644 --- a/include/sdf/Projector.hh +++ b/include/sdf/Projector.hh @@ -45,6 +45,9 @@ namespace sdf /// \brief Default constructor public: Projector(); + /// \brief Get the schema file name accessor + public: static inline std::string_view SchemaFile(); + /// \brief Load the projector based on an element pointer. This is /// *not* the usual entry point. Typical usage of the SDF DOM is through /// the Root object. diff --git a/include/sdf/Root.hh b/include/sdf/Root.hh index 9ad5f1632..a8c823cf2 100644 --- a/include/sdf/Root.hh +++ b/include/sdf/Root.hh @@ -59,6 +59,9 @@ namespace sdf /// \brief Default constructor public: Root(); + /// \brief Get the schema file name accessor + public: static inline std::string_view SchemaFile(); + /// \brief Get the name of the world without loading the entire world /// Users shouldn't normally need to use this API. /// This doesn't load the world, it might return the world name even if the diff --git a/include/sdf/Scene.hh b/include/sdf/Scene.hh index e11f51596..5c33334c3 100644 --- a/include/sdf/Scene.hh +++ b/include/sdf/Scene.hh @@ -35,6 +35,9 @@ namespace sdf /// \brief Default constructor public: Scene(); + /// \brief Get the schema file name accessor + public: static inline std::string_view SchemaFile(); + /// \brief Load the scene based on a element pointer. This is *not* the /// usual entry point. Typical usage of the SDF DOM is through the Root /// object. diff --git a/include/sdf/Sensor.hh b/include/sdf/Sensor.hh index 7b62572ec..38c3f1fce 100644 --- a/include/sdf/Sensor.hh +++ b/include/sdf/Sensor.hh @@ -142,6 +142,9 @@ namespace sdf /// \brief Default constructor public: Sensor(); + /// \brief Get the schema file name accessor + public: static inline std::string_view SchemaFile(); + /// \brief Load the sensor based on a element pointer. This is *not* the /// usual entry point. Typical usage of the SDF DOM is through the Root /// object. diff --git a/include/sdf/Surface.hh b/include/sdf/Surface.hh index 02fd98be5..ad855d3a4 100644 --- a/include/sdf/Surface.hh +++ b/include/sdf/Surface.hh @@ -161,6 +161,9 @@ namespace sdf /// \brief Default constructor public: Surface(); + /// \brief Get the schema file name accessor + public: static inline std::string_view SchemaFile(); + /// \brief Load the surface based on a element pointer. This is *not* the /// usual entry point. Typical usage of the SDF DOM is through the Root /// object. diff --git a/include/sdf/Visual.hh b/include/sdf/Visual.hh index ff9da957f..571cfcdd9 100644 --- a/include/sdf/Visual.hh +++ b/include/sdf/Visual.hh @@ -50,6 +50,9 @@ namespace sdf /// \brief Default constructor public: Visual(); + /// \brief Get the schema file name accessor + public: static inline std::string_view SchemaFile(); + /// \brief Load the visual based on a element pointer. This is *not* the /// usual entry point. Typical usage of the SDF DOM is through the Root /// object. diff --git a/include/sdf/World.hh b/include/sdf/World.hh index 7e449abab..4d68a3dcc 100644 --- a/include/sdf/World.hh +++ b/include/sdf/World.hh @@ -60,6 +60,9 @@ namespace sdf /// \brief Default constructor public: World(); + /// \brief Get the schema file name accessor + public: static inline std::string_view SchemaFile(); + /// \brief Load the world based on a element pointer. This is *not* the /// usual entry point. Typical usage of the SDF DOM is through the Root /// object. diff --git a/src/Actor.cc b/src/Actor.cc index 0a0eebb93..595ef1f8b 100644 --- a/src/Actor.cc +++ b/src/Actor.cc @@ -819,3 +819,11 @@ void Actor::AddPlugin(const Plugin &_plugin) { this->dataPtr->plugins.push_back(_plugin); } + +///////////////////////////////////////////////// +inline std::string_view Actor::SchemaFile() +{ + static char kSchemaFile[] = "actor.sdf"; + return kSchemaFile; +} + diff --git a/src/AirPressure.cc b/src/AirPressure.cc index 9cc58a8a0..fdbdc5b35 100644 --- a/src/AirPressure.cc +++ b/src/AirPressure.cc @@ -139,3 +139,11 @@ sdf::ElementPtr AirPressure::ToElement(sdf::Errors &_errors) const return elem; } + +///////////////////////////////////////////////// +inline std::string_view AirPressure::SchemaFile() +{ + static char kSchemaFile[] = "air_pressure.sdf"; + return kSchemaFile; +} + diff --git a/src/AirSpeed.cc b/src/AirSpeed.cc index 2ca0e16c9..0045f6ac4 100644 --- a/src/AirSpeed.cc +++ b/src/AirSpeed.cc @@ -106,3 +106,11 @@ sdf::ElementPtr AirSpeed::ToElement() const return elem; } + +///////////////////////////////////////////////// +inline std::string_view AirSpeed::SchemaFile() +{ + static char kSchemaFile[] = "air_speed.sdf"; + return kSchemaFile; +} + diff --git a/src/Altimeter.cc b/src/Altimeter.cc index 83fcad037..638ebcc88 100644 --- a/src/Altimeter.cc +++ b/src/Altimeter.cc @@ -169,3 +169,11 @@ sdf::ElementPtr Altimeter::ToElement(sdf::Errors &_errors) const return elem; } + +///////////////////////////////////////////////// +inline std::string_view Altimeter::SchemaFile() +{ + static char kSchemaFile[] = "altimeter.sdf"; + return kSchemaFile; +} + diff --git a/src/Atmosphere.cc b/src/Atmosphere.cc index 597504658..9ff3e14b4 100644 --- a/src/Atmosphere.cc +++ b/src/Atmosphere.cc @@ -172,3 +172,11 @@ sdf::ElementPtr Atmosphere::ToElement(sdf::Errors &_errors) const return elem; } + +///////////////////////////////////////////////// +inline std::string_view Atmosphere::SchemaFile() +{ + static char kSchemaFile[] = "atmosphere.sdf"; + return kSchemaFile; +} + diff --git a/src/Camera.cc b/src/Camera.cc index 2f2ea7a2b..78ed66de7 100644 --- a/src/Camera.cc +++ b/src/Camera.cc @@ -1337,3 +1337,11 @@ sdf::ElementPtr Camera::ToElement() const return elem; } + +///////////////////////////////////////////////// +inline std::string_view Camera::SchemaFile() +{ + static char kSchemaFile[] = "camera.sdf"; + return kSchemaFile; +} + diff --git a/src/Collision.cc b/src/Collision.cc index ca944712d..e78481e60 100644 --- a/src/Collision.cc +++ b/src/Collision.cc @@ -392,3 +392,11 @@ sdf::ElementPtr Collision::ToElement(sdf::Errors &_errors) const return elem; } + +///////////////////////////////////////////////// +inline std::string_view Collision::SchemaFile() +{ + static char kSchemaFile[] = "collision.sdf"; + return kSchemaFile; +} + diff --git a/src/ForceTorque.cc b/src/ForceTorque.cc index 4386629c1..e48e0c39b 100644 --- a/src/ForceTorque.cc +++ b/src/ForceTorque.cc @@ -367,3 +367,11 @@ sdf::ElementPtr ForceTorque::ToElement(sdf::Errors &_errors) const return elem; } + +///////////////////////////////////////////////// +inline std::string_view ForceTorque::SchemaFile() +{ + static char kSchemaFile[] = "forcetorque.sdf"; + return kSchemaFile; +} + diff --git a/src/Frame.cc b/src/Frame.cc index de9870915..a12e1f7bc 100644 --- a/src/Frame.cc +++ b/src/Frame.cc @@ -250,3 +250,11 @@ sdf::ElementPtr Frame::ToElement(sdf::Errors &_errors) const return elem; } + +///////////////////////////////////////////////// +inline std::string_view Frame::SchemaFile() +{ + static char kSchemaFile[] = "frame.sdf"; + return kSchemaFile; +} + diff --git a/src/Geometry.cc b/src/Geometry.cc index 9afb20212..d4f73508b 100644 --- a/src/Geometry.cc +++ b/src/Geometry.cc @@ -421,3 +421,11 @@ sdf::ElementPtr Geometry::ToElement(sdf::Errors &_errors) const return elem; } + +///////////////////////////////////////////////// +inline std::string_view Geometry::SchemaFile() +{ + static char kSchemaFile[] = "geometry.sdf"; + return kSchemaFile; +} + diff --git a/src/Gui.cc b/src/Gui.cc index f64fd61ca..f48b7dd8c 100644 --- a/src/Gui.cc +++ b/src/Gui.cc @@ -147,3 +147,11 @@ sdf::Plugins &Gui::Plugins() } + +///////////////////////////////////////////////// +inline std::string_view Gui::SchemaFile() +{ + static char kSchemaFile[] = "gui.sdf"; + return kSchemaFile; +} + diff --git a/src/Imu.cc b/src/Imu.cc index 65ea2e6e6..644ea095c 100644 --- a/src/Imu.cc +++ b/src/Imu.cc @@ -454,3 +454,11 @@ sdf::ElementPtr Imu::ToElement(sdf::Errors &_errors) const return elem; } + +///////////////////////////////////////////////// +inline std::string_view Imu::SchemaFile() +{ + static char kSchemaFile[] = "imu.sdf"; + return kSchemaFile; +} + diff --git a/src/Joint.cc b/src/Joint.cc index 2b8fd8282..ae4a79398 100644 --- a/src/Joint.cc +++ b/src/Joint.cc @@ -630,3 +630,11 @@ void Joint::ClearSensors() { this->dataPtr->sensors.clear(); } + +///////////////////////////////////////////////// +inline std::string_view Joint::SchemaFile() +{ + static char kSchemaFile[] = "joint.sdf"; + return kSchemaFile; +} + diff --git a/src/Lidar.cc b/src/Lidar.cc index 56803c695..314501a2b 100644 --- a/src/Lidar.cc +++ b/src/Lidar.cc @@ -450,3 +450,11 @@ sdf::ElementPtr Lidar::ToElement() const return elem; } + +///////////////////////////////////////////////// +inline std::string_view Lidar::SchemaFile() +{ + static char kSchemaFile[] = "lidar.sdf"; + return kSchemaFile; +} + diff --git a/src/Light.cc b/src/Light.cc index 02fb48001..fde792633 100644 --- a/src/Light.cc +++ b/src/Light.cc @@ -556,3 +556,11 @@ sdf::ElementPtr Light::ToElement(sdf::Errors &_errors) const _errors, this->SpotFalloff()); return elem; } + +///////////////////////////////////////////////// +inline std::string_view Light::SchemaFile() +{ + static char kSchemaFile[] = "light.sdf"; + return kSchemaFile; +} + diff --git a/src/Link.cc b/src/Link.cc index 085feab93..2d88af046 100644 --- a/src/Link.cc +++ b/src/Link.cc @@ -1060,3 +1060,11 @@ sdf::ElementPtr Link::ToElement() const return elem; } + +///////////////////////////////////////////////// +inline std::string_view Link::SchemaFile() +{ + static char kSchemaFile[] = "link.sdf"; + return kSchemaFile; +} + diff --git a/src/Magnetometer.cc b/src/Magnetometer.cc index 80498158d..452d6acd1 100644 --- a/src/Magnetometer.cc +++ b/src/Magnetometer.cc @@ -155,3 +155,11 @@ sdf::ElementPtr Magnetometer::ToElement() const return elem; } + +///////////////////////////////////////////////// +inline std::string_view Magnetometer::SchemaFile() +{ + static char kSchemaFile[] = "magnetometer.sdf"; + return kSchemaFile; +} + diff --git a/src/Material.cc b/src/Material.cc index 6a0456686..30939e0b5 100644 --- a/src/Material.cc +++ b/src/Material.cc @@ -528,3 +528,11 @@ sdf::ElementPtr Material::ToElement(sdf::Errors &_errors) const return elem; } + +///////////////////////////////////////////////// +inline std::string_view Material::SchemaFile() +{ + static char kSchemaFile[] = "material.sdf"; + return kSchemaFile; +} + diff --git a/src/Model.cc b/src/Model.cc index 944e50b87..2d846b56b 100644 --- a/src/Model.cc +++ b/src/Model.cc @@ -1414,3 +1414,11 @@ sdf::Frame Model::PrepareForMerge(sdf::Errors &_errors, return proxyFrame; } + +///////////////////////////////////////////////// +inline std::string_view Model::SchemaFile() +{ + static char kSchemaFile[] = "model.sdf"; + return kSchemaFile; +} + diff --git a/src/NavSat.cc b/src/NavSat.cc index 8ab7d7e64..7372ff994 100644 --- a/src/NavSat.cc +++ b/src/NavSat.cc @@ -191,3 +191,11 @@ bool NavSat::operator!=(const NavSat &_navsat) const { return !(*this == _navsat); } + +///////////////////////////////////////////////// +inline std::string_view NavSat::SchemaFile() +{ + static char kSchemaFile[] = "navsat.sdf"; + return kSchemaFile; +} + diff --git a/src/Noise.cc b/src/Noise.cc index b4507e957..a971b672c 100644 --- a/src/Noise.cc +++ b/src/Noise.cc @@ -300,3 +300,11 @@ sdf::ElementPtr Noise::ToElement(sdf::Errors &_errors) const return elem; } + +///////////////////////////////////////////////// +inline std::string_view Noise::SchemaFile() +{ + static char kSchemaFile[] = "noise.sdf"; + return kSchemaFile; +} + diff --git a/src/ParticleEmitter.cc b/src/ParticleEmitter.cc index 605b58812..dfc36aea8 100644 --- a/src/ParticleEmitter.cc +++ b/src/ParticleEmitter.cc @@ -573,3 +573,11 @@ sdf::ElementPtr ParticleEmitter::ToElement(sdf::Errors &_errors) const } + +///////////////////////////////////////////////// +inline std::string_view ParticleEmitter::SchemaFile() +{ + static char kSchemaFile[] = "particle_emitter.sdf"; + return kSchemaFile; +} + diff --git a/src/Physics.cc b/src/Physics.cc index b9dd69317..1af423242 100644 --- a/src/Physics.cc +++ b/src/Physics.cc @@ -232,3 +232,11 @@ sdf::ElementPtr Physics::ToElement(sdf::Errors &_errors) const return elem; } + +///////////////////////////////////////////////// +inline std::string_view Physics::SchemaFile() +{ + static char kSchemaFile[] = "physics.sdf"; + return kSchemaFile; +} + diff --git a/src/Plugin.cc b/src/Plugin.cc index c85563519..d0b5d7572 100644 --- a/src/Plugin.cc +++ b/src/Plugin.cc @@ -311,3 +311,11 @@ bool Plugin::operator!=(const Plugin &_plugin) const { return !(*this == _plugin); } + +///////////////////////////////////////////////// +inline std::string_view Plugin::SchemaFile() +{ + static char kSchemaFile[] = "plugin.sdf"; + return kSchemaFile; +} + diff --git a/src/Projector.cc b/src/Projector.cc index b8c1f7b98..7b851e973 100644 --- a/src/Projector.cc +++ b/src/Projector.cc @@ -331,3 +331,11 @@ sdf::ElementPtr Projector::ToElement() const return elem; } + +///////////////////////////////////////////////// +inline std::string_view Projector::SchemaFile() +{ + static char kSchemaFile[] = "projector.sdf"; + return kSchemaFile; +} + diff --git a/src/Root.cc b/src/Root.cc index 03349d2af..0d3210684 100644 --- a/src/Root.cc +++ b/src/Root.cc @@ -644,3 +644,11 @@ sdf::ElementPtr Root::ToElement(const OutputConfig &_config) const return elem; } + +///////////////////////////////////////////////// +inline std::string_view Root::SchemaFile() +{ + static char kSchemaFile[] = "root.sdf"; + return kSchemaFile; +} + diff --git a/src/Scene.cc b/src/Scene.cc index 429d16aee..52e53373b 100644 --- a/src/Scene.cc +++ b/src/Scene.cc @@ -212,3 +212,11 @@ sdf::ElementPtr Scene::ToElement(sdf::Errors &_errors) const return elem; } + +///////////////////////////////////////////////// +inline std::string_view Scene::SchemaFile() +{ + static char kSchemaFile[] = "scene.sdf"; + return kSchemaFile; +} + diff --git a/src/Sensor.cc b/src/Sensor.cc index 78ac7087b..15fcdd455 100644 --- a/src/Sensor.cc +++ b/src/Sensor.cc @@ -848,3 +848,11 @@ void Sensor::AddPlugin(const Plugin &_plugin) { this->dataPtr->plugins.push_back(_plugin); } + +///////////////////////////////////////////////// +inline std::string_view Sensor::SchemaFile() +{ + static char kSchemaFile[] = "sensor.sdf"; + return kSchemaFile; +} + diff --git a/src/Surface.cc b/src/Surface.cc index 5bc84970d..22b48e198 100644 --- a/src/Surface.cc +++ b/src/Surface.cc @@ -431,3 +431,11 @@ sdf::ElementPtr Surface::ToElement(sdf::Errors &_errors) const return elem; } + +///////////////////////////////////////////////// +inline std::string_view Surface::SchemaFile() +{ + static char kSchemaFile[] = "surface.sdf"; + return kSchemaFile; +} + diff --git a/src/Visual.cc b/src/Visual.cc index 5ffdf3d33..685c26e9b 100644 --- a/src/Visual.cc +++ b/src/Visual.cc @@ -378,3 +378,11 @@ void Visual::AddPlugin(const Plugin &_plugin) { this->dataPtr->plugins.push_back(_plugin); } + +///////////////////////////////////////////////// +inline std::string_view Visual::SchemaFile() +{ + static char kSchemaFile[] = "visual.sdf"; + return kSchemaFile; +} + diff --git a/src/World.cc b/src/World.cc index d94ff685a..fa1f939ce 100644 --- a/src/World.cc +++ b/src/World.cc @@ -1271,3 +1271,11 @@ void World::AddPlugin(const Plugin &_plugin) { this->dataPtr->plugins.push_back(_plugin); } + +///////////////////////////////////////////////// +inline std::string_view World::SchemaFile() +{ + static char kSchemaFile[] = "world.sdf"; + return kSchemaFile; +} + diff --git a/tools/format_schema.py b/tools/format_schema.py new file mode 100644 index 000000000..ebaa97faa --- /dev/null +++ b/tools/format_schema.py @@ -0,0 +1,67 @@ +import os + +lines = os.listdir('./sdf/1.11/') +# Only keep the files that end with .sdf +lines = [line for line in lines if line.endswith('.sdf')] + +for line in lines: + # Remove .sdf extension + snake_case = line.strip().split('.')[0] + + # Convert from snake_case to CamelCase + camel_case = ''.join([word.capitalize() for word in snake_case.split('_')]) + + addHeader = """ + /// \\brief Get the schema file name accessor + public: static inline std::string_view SchemaFile(); + """ + + addImpl = f""" +///////////////////////////////////////////////// +inline std::string_view {camel_case}::SchemaFile() +{{ + static const char kSchemaFile[] = "{line}"; + return kSchemaFile; +}}\n\n""" + + # Debug print statements + # print(addHeader) + # print(addImpl) + # print(addTest) + # print("\n") + + # Edit './include/sdf/{camel_case}.hh' + # Find the line with 'class SDFFORMAT_VISIBLE {camel_case}` + try: + f = open('./include/sdf/' + camel_case + '.hh', 'r') + lines = f.readlines() + f.close() + line_number = 0 + for i, line in enumerate(lines): + if line == " class SDFORMAT_VISIBLE " + camel_case + '\n': + line_number = i+3 # After the class line there is `\n{\n` and then the constructor + break + if line_number == 0: + print("Error: Could not find class declaration in " + camel_case + ".hh") + exit(1) + + try: + with open('./include/sdf/' + camel_case + '.hh', 'w') as file: + for i, line in enumerate(lines): + file.write(line) + if i == line_number: + file.write(addHeader) + except: + print("Unexpected error while writing to: " + camel_case + ".hh.") + except: + print("Error while writing to: " + camel_case + ".hh." + " Check if file exists.") + + # Edit './src/{camel_case}.cc' if it exists + # Add implementation to end of document + if os.path.exists('./src/' + camel_case + '.cc'): + with open('./src/' + camel_case + '.cc', 'a') as file: + file.write(addImpl) + else: + print("Error: Could not find " + camel_case + ".cc") + + print("Changes written to source successfully")