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 
39 namespace 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
sdf::v9::addURIPath
SDFORMAT_VISIBLE void addURIPath(const std::string &_uri, const std::string &_path)
Associate paths to a URI.
sdf::v9::SDFPtr
std::shared_ptr< SDF > SDFPtr
Definition: SDFImpl.hh:50
sdf
namespace for Simulation Description Format parser
Definition: Actor.hh:32
Types.hh
SDFORMAT_VISIBLE
#define SDFORMAT_VISIBLE
Definition: system_util.hh:48
sdf::v9::findFile
SDFORMAT_VISIBLE std::string findFile(const std::string &_filename, bool _searchLocalPath=true, bool _useCallback=false)
Find the absolute path of a file.
sdf::v9::SDF
class SDFORMAT_VISIBLE SDF
Definition: SDFImpl.hh:45
Param.hh
sdf::v9::Root
Root class that acts as an entry point to the SDF document model.
Definition: Root.hh:54
sdf::v9::SDF
Base SDF class.
Definition: SDFImpl.hh:83
sdf::v9::ElementPtr
std::shared_ptr< Element > ElementPtr
Definition: Element.hh:53
sdf::v9::setFindCallback
SDFORMAT_VISIBLE void setFindCallback(std::function< std::string(const std::string &)> _cb)
Set the callback to use when SDF can't find a file.
system_util.hh
Element.hh