-
Notifications
You must be signed in to change notification settings - Fork 91
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
Added plugin to SDF DOM #788
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
fcb8feb
Added plugin to SDF DOM
00261ce
tweaks
74bd0d1
Fixed doxygen
1f3b675
Updates
980d5d2
Update plugin copy and tests
a305c2f
Merge branch 'sdf12' into plugin_dom
nkoenig cd4e1b9
Remove string and add move functions
9996e03
Fix build and tests
60dc7cd
Fix windows warnings
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,6 +47,7 @@ set (headers | |
Pbr.hh | ||
Physics.hh | ||
Plane.hh | ||
Plugin.hh | ||
PrintConfig.hh | ||
Root.hh | ||
Scene.hh | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
/* | ||
* Copyright 2021 Open Source Robotics Foundation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
#ifndef SDF_PLUGIN_HH_ | ||
#define SDF_PLUGIN_HH_ | ||
|
||
#include <memory> | ||
#include <string> | ||
#include <vector> | ||
|
||
#include <sdf/Element.hh> | ||
#include <sdf/Error.hh> | ||
#include <sdf/Types.hh> | ||
#include "sdf/sdf_config.h" | ||
#include "sdf/system_util.hh" | ||
|
||
#ifdef _WIN32 | ||
// Disable warning C4251 which is triggered by | ||
// std::unique_ptr | ||
#pragma warning(push) | ||
#pragma warning(disable: 4251) | ||
#endif | ||
|
||
namespace sdf | ||
{ | ||
// Inline bracket to help doxygen filtering. | ||
inline namespace SDF_VERSION_NAMESPACE { | ||
// | ||
class PluginPrivate; | ||
|
||
class SDFORMAT_VISIBLE Plugin | ||
{ | ||
/// \brief Default constructor | ||
public: Plugin(); | ||
|
||
/// \brief Default destructor | ||
public: ~Plugin(); | ||
|
||
/// \brief Copy constructor. | ||
/// \param[in] _plugin Plugin to copy. | ||
public: Plugin(const Plugin &_plugin); | ||
|
||
/// \brief Move constructor. | ||
/// \param[in] _plugin Plugin to copy. | ||
public: Plugin(Plugin &&_plugin) noexcept; | ||
|
||
/// \brief Load the plugin based on a element pointer. This is *not* the | ||
/// usual entry point. Typical usage of the SDF DOM is through the Root | ||
/// object. | ||
/// \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: Errors Load(ElementPtr _sdf); | ||
|
||
/// \brief Get the name of the plugin. | ||
/// The name of the plugin should be unique within the scope of its | ||
/// parent. | ||
/// \return Name of the plugin. | ||
public: std::string Name() const; | ||
|
||
/// \brief Set the name of the plugin. | ||
/// The name of the plugin should be unique within the scope of its | ||
/// parent. | ||
/// \param[in] _name Name of the plugin. | ||
public: void SetName(const std::string &_name); | ||
|
||
/// \brief Get the filename of the shared library. | ||
/// \return Filename of the shared library associated with the plugin. | ||
public: std::string Filename() const; | ||
|
||
/// \brief Remove the contents of the plugin, this is everything that | ||
/// is a child element of the `<plugin>`. | ||
public: void ClearContents(); | ||
|
||
/// \brief Get the plugin contents. This is all the SDF elements that | ||
/// are children of the `<plugin>`. | ||
/// \return The child elements of this plugin. | ||
public: const std::vector<sdf::ElementPtr> &Contents() const; | ||
|
||
/// \brief Insert an element into the plugin content. This does not | ||
/// modify the values in the sdf::ElementPtr returned by the `Element()` | ||
/// function. | ||
/// \param[in] _elem Element to insert. | ||
public: void InsertContent(const sdf::ElementPtr _elem); | ||
azeey marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
/// \brief Set the filename of the shared library. | ||
/// \param[in] _filename Filename of the shared library associated with | ||
/// this plugin. | ||
public: void SetFilename(const std::string &_filename); | ||
|
||
/// \brief Get a pointer to the SDF element that was used during | ||
/// load. | ||
/// \return SDF element pointer. The value will be nullptr if Load has | ||
/// not been called. | ||
public: sdf::ElementPtr Element() const; | ||
|
||
/// \brief Create and return an SDF element filled with data from this | ||
/// plugin. | ||
/// \return SDF element pointer with updated plugin values. | ||
public: sdf::ElementPtr ToElement() const; | ||
|
||
/// \brief Copy assignment operator | ||
/// \param[in] _plugin Plugin to copy | ||
/// \return A reference to this plugin | ||
public: Plugin &operator=(const Plugin &_plugin); | ||
|
||
/// \brief Move assignment operator | ||
/// \param[in] _plugin Plugin to move | ||
/// \return A reference to this plugin | ||
public: Plugin &operator=(Plugin &&_plugin) noexcept; | ||
|
||
/// \brief Private data pointer. | ||
std::unique_ptr<sdf::PluginPrivate> dataPtr; | ||
}; | ||
} | ||
} | ||
|
||
#ifdef _WIN32 | ||
#pragma warning(pop) | ||
#endif | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll need to add move constructor and move assignment as well per the rule of five.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
was there a reason we didn't use ImplPtr here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it because we need to take care to clone the
sdf::ElementPtr
contents instead of just copying the shared pointer?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Here's more context: https://github.com/ignitionrobotics/sdformat/pull/788/files#r770912499