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/system_util.hh"
27 #include "sdf/Types.hh"
28 
29 #ifdef _WIN32
30 // Disable warning C4251 which is triggered by
31 // std::unique_ptr
32 #pragma warning(push)
33 #pragma warning(disable: 4251)
34 #endif
35 
38 namespace sdf
39 {
40  class SDFORMAT_VISIBLE SDF;
41 
44  typedef std::shared_ptr<SDF> SDFPtr;
45 
48 
57  std::string findFile(const std::string &_filename,
58  bool _searchLocalPath = true,
59  bool _useCallback = false);
60 
66  void addURIPath(const std::string &_uri, const std::string &_path);
67 
73  void setFindCallback(std::function<std::string (const std::string &)> _cb);
74 
75  class SDFPrivate;
76 
79  {
80  public: SDF();
82  public: ~SDF();
83  public: void PrintDescription();
84  public: void PrintValues();
85  public: void PrintDoc();
86  public: void Write(const std::string &_filename);
87  public: std::string ToString() const;
88 
90  public: void SetFromString(const std::string &_sdfData);
91 
94  public: ElementPtr Root() const;
95 
98  public: void Root(const ElementPtr _root);
99 
102  public: static std::string Version();
103 
106  public: static void Version(const std::string &_version);
107 
111  public: static ElementPtr WrapInRoot(const ElementPtr &_sdf);
112 
115  private: std::unique_ptr<SDFPrivate> dataPtr;
116 
119  private: static std::string version;
120  };
122 }
123 
124 #ifdef _WIN32
125 #pragma warning(pop)
126 #endif
127 
128 #endif
sdf::SDF::Version
static void Version(const std::string &_version)
Set the version string.
sdf::SDF::PrintValues
void PrintValues()
sdf::SDF::PrintDescription
void PrintDescription()
sdf::SDF::Root
ElementPtr Root() const
Get a pointer to the root element.
sdf
namespace for Simulation Description Format parser
Definition: Console.hh:36
sdf::SDF::SDF
SDF()
Types.hh
sdf::SDF::ToString
std::string ToString() const
SDFORMAT_VISIBLE
#define SDFORMAT_VISIBLE
Definition: system_util.hh:48
sdf::SDF::SetFromString
void SetFromString(const std::string &_sdfData)
Set SDF values from a string.
sdf::SDFPtr
std::shared_ptr< SDF > SDFPtr
Definition: SDFImpl.hh:44
sdf::SDF
Base SDF class.
Definition: SDFImpl.hh:79
Param.hh
sdf::ElementPtr
std::shared_ptr< Element > ElementPtr
Definition: Element.hh:45
sdf::SDF::Root
void Root(const ElementPtr _root)
Set the root pointer.
sdf::SDF::~SDF
~SDF()
Destructor.
sdf::SDF::WrapInRoot
static ElementPtr WrapInRoot(const ElementPtr &_sdf)
wraps the SDF element into a root element with the version info.
sdf::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.
sdf::SDFPrivate
Private data for base SDF class.
Definition: SDFImplPrivate.hh:28
sdf::SDF::Write
void Write(const std::string &_filename)
sdf::addURIPath
SDFORMAT_VISIBLE void addURIPath(const std::string &_uri, const std::string &_path)
Associate paths to a URI.
system_util.hh
sdf::findFile
SDFORMAT_VISIBLE std::string findFile(const std::string &_filename, bool _searchLocalPath=true, bool _useCallback=false)
Find the absolute path of a file.
sdf::SDF::Version
static std::string Version()
Get the version.
sdf::SDF::PrintDoc
void PrintDoc()
Element.hh