Loading...
Searching...
No Matches
SDFImpl.hh
Go to the documentation of this file.
1/*
2 * Copyright 2012 Open Source Robotics Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16*/
17#ifndef SDFIMPL_HH_
18#define SDFIMPL_HH_
19
20#include <functional>
21#include <memory>
22#include <string>
23
24#include "sdf/Param.hh"
25#include "sdf/Element.hh"
26#include "sdf/sdf_config.h"
27#include "sdf/system_util.hh"
28#include "sdf/Types.hh"
29
30#ifdef _WIN32
31// Disable warning C4251 which is triggered by
32// std::unique_ptr
33#pragma warning(push)
34#pragma warning(disable: 4251)
35#endif
36
39namespace sdf
40{
41 // Inline bracket to help doxygen filtering.
42 inline namespace SDF_VERSION_NAMESPACE {
43 //
44
46 class SDFPrivate;
47
50 typedef std::shared_ptr<SDF> SDFPtr;
51
54
63 std::string findFile(const std::string &_filename,
64 bool _searchLocalPath = true,
65 bool _useCallback = false);
66
72 void addURIPath(const std::string &_uri, const std::string &_path);
73
79 void setFindCallback(std::function<std::string (const std::string &)> _cb);
80
81
84 {
85 public: SDF();
87 public: ~SDF();
88 public: void PrintDescription();
89 public: void PrintValues();
90 public: void PrintDoc();
91 public: void Write(const std::string &_filename);
92 public: std::string ToString() const;
93
95 public: void SetFromString(const std::string &_sdfData);
96
98 public: void Clear();
99
102 public: ElementPtr Root() const;
103
106 public: void Root(const ElementPtr _root);
107
110 public: std::string FilePath() const;
111
114 public: void SetFilePath(const std::string &_path);
115
118 public: void SetOriginalVersion(const std::string &_version);
119
122 public: const std::string &OriginalVersion() const;
123
126 public: static std::string Version();
127
130 public: static void Version(const std::string &_version);
131
135 public: static ElementPtr WrapInRoot(const ElementPtr &_sdf);
136
150 public: static const std::string &EmbeddedSpec(
151 const std::string &_filename, const bool _quiet);
152
155 private: std::unique_ptr<SDFPrivate> dataPtr;
156
159 private: static std::string version;
160 };
162 }
163}
164
165#ifdef _WIN32
166#pragma warning(pop)
167#endif
168
169#endif
Base SDF class.
Definition SDFImpl.hh:84
~SDF()
Destructor.
static std::string Version()
Get the version.
void PrintDescription()
ElementPtr Root() const
Get a pointer to the root element.
const std::string & OriginalVersion() const
Get the spec version that this was originally parsed from.
void Root(const ElementPtr _root)
Set the root pointer.
void PrintValues()
void SetFromString(const std::string &_sdfData)
Set SDF values from a string.
void PrintDoc()
void SetFilePath(const std::string &_path)
Set the path on disk.
void Write(const std::string &_filename)
static void Version(const std::string &_version)
Set the version string.
void Clear()
Clear the data in this object.
static ElementPtr WrapInRoot(const ElementPtr &_sdf)
wraps the SDF element into a root element with the version info.
static const std::string & EmbeddedSpec(const std::string &_filename, const bool _quiet)
Get a string representation of an SDF specification file.
std::string FilePath() const
Get the path to the SDF document on disk.
void SetOriginalVersion(const std::string &_version)
Set the spec version that this was originally parsed from.
std::string ToString() const
SDFORMAT_VISIBLE void addURIPath(const std::string &_uri, const std::string &_path)
Associate paths to a URI.
SDFORMAT_VISIBLE void setFindCallback(std::function< std::string(const std::string &)> _cb)
Set the callback to use when SDF can't find a file.
SDFORMAT_VISIBLE std::string findFile(const std::string &_filename, bool _searchLocalPath=true, bool _useCallback=false)
Find the absolute path of a file.
std::shared_ptr< SDF > SDFPtr
Definition SDFImpl.hh:50
std::shared_ptr< Element > ElementPtr
Definition Element.hh:53
namespace for Simulation Description Format parser
Definition Actor.hh:33
#define SDFORMAT_VISIBLE
Use to represent "symbol visible" if supported.
Definition system_util.hh:48