DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
UriReader.h
Go to the documentation of this file.
1 //==========================================================================
2 // AIDA Detector description implementation
3 //--------------------------------------------------------------------------
4 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
5 // All rights reserved.
6 //
7 // For the licensing terms see $DD4hepINSTALL/LICENSE.
8 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
9 //
10 // Author : M.Frank
11 //
12 //==========================================================================
13 #ifndef XML_URIREADER_H
14 #define XML_URIREADER_H
15 
16 // C/C++ include files
17 #include <string>
18 
20 namespace dd4hep {
21 
23  namespace xml {
24 
26 
35  class UriReader {
36  public:
38  /* User overloaded extensions hole the information necessary
39  * to perform the entity resolution
40  *
41  * \author M.Frank
42  * \version 1.0
43  * \ingroup DD4HEP_XML
44  */
45  struct UserContext {
46  UserContext() = default;
47  UserContext(const UserContext&) = default;
48  virtual ~UserContext() = default;
49  };
50  public:
52  UriReader() = default;
54  virtual ~UriReader();
56  virtual UserContext* context() = 0;
58  virtual void blockPath(const std::string& /* path */) {}
61  virtual bool isBlocked(const std::string& /* path */) const { return false; }
63  virtual bool load(const std::string& system_id, std::string& data);
65  virtual bool load(const std::string& system_id, UserContext* context, std::string& data) = 0;
67  virtual void parserLoaded(const std::string& system_id);
69  virtual void parserLoaded(const std::string& system_id, UserContext* ctxt) = 0;
70  };
71 
73 
83  class UriContextReader : public UriReader {
84  protected:
89  public:
95  virtual ~UriContextReader();
97  virtual UserContext* context() override { return m_context; }
99  virtual void blockPath(const std::string& path) override;
102  virtual bool isBlocked(const std::string& path) const override;
104  virtual bool load(const std::string& system_id, std::string& data) override;
106  virtual bool load(const std::string& system_id, UserContext* context, std::string& data) override;
108  virtual void parserLoaded(const std::string& system_id) override;
110  virtual void parserLoaded(const std::string& system_id, UserContext* ctxt) override;
111  };
112 
113  } /* End namespace xml */
114 } /* End namespace dd4hep */
115 #endif // XML_URIREADER_H
dd4hep::xml::UriReader::blockPath
virtual void blockPath(const std::string &)
Add a blocked path entry.
Definition: UriReader.h:59
dd4hep::xml::UriContextReader
Class supporting to read data given a URI.
Definition: UriReader.h:83
dd4hep::xml::UriReader::isBlocked
virtual bool isBlocked(const std::string &) const
Check if a URI path is blocked.
Definition: UriReader.h:61
dd4hep::xml::UriReader::load
virtual bool load(const std::string &system_id, std::string &data)
Resolve a given URI to a string containing the data.
Definition: UriReader.cpp:22
dd4hep::xml::UriContextReader::context
virtual UserContext * context() override
Access to local context.
Definition: UriReader.h:97
dd4hep::xml::UriContextReader::~UriContextReader
virtual ~UriContextReader()
Default destructor.
Definition: UriReader.cpp:44
dd4hep::xml::UriReader::parserLoaded
virtual void parserLoaded(const std::string &system_id, UserContext *ctxt)=0
Inform reader about a locally (e.g. by XercesC) handled source load.
dd4hep::xml::UriContextReader::UriContextReader
UriContextReader(UriReader *reader, UriReader::UserContext *ctxt)
Default initializing constructor.
Definition: UriReader.cpp:32
dd4hep::xml::UriReader::parserLoaded
virtual void parserLoaded(const std::string &system_id)
Inform reader about a locally (e.g. by XercesC) handled source load.
Definition: UriReader.cpp:27
dd4hep::xml::UriContextReader::m_reader
UriReader * m_reader
Pointer to true reader object.
Definition: UriReader.h:86
dd4hep::xml::UriReader::UserContext::~UserContext
virtual ~UserContext()=default
dd4hep::xml::UriContextReader::m_context
UriReader::UserContext * m_context
Pointer to user context.
Definition: UriReader.h:88
dd4hep::xml::UriReader::UriReader
UriReader()=default
Default constructor.
dd4hep::xml
Namespace for the AIDA detector description toolkit supporting XML utilities.
Definition: ConditionsTags.h:27
dd4hep::xml::UriContextReader::parserLoaded
virtual void parserLoaded(const std::string &system_id) override
Inform reader about a locally (e.g. by XercesC) handled source load.
Definition: UriReader.cpp:68
dd4hep::xml::UriContextReader::load
virtual bool load(const std::string &system_id, std::string &data) override
Resolve a given URI to a string containing the data.
Definition: UriReader.cpp:58
dd4hep::xml::UriReader::UserContext::UserContext
UserContext()=default
dd4hep::xml::UriReader::~UriReader
virtual ~UriReader()
Default destructor.
Definition: UriReader.cpp:18
dd4hep::xml::UriReader
Class supporting to read data given a URI.
Definition: UriReader.h:35
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
dd4hep::xml::UriReader::UserContext::UserContext
UserContext(const UserContext &)=default
dd4hep::xml::UriContextReader::blockPath
virtual void blockPath(const std::string &path) override
Add a blocked path entry.
Definition: UriReader.cpp:48
dd4hep::xml::UriContextReader::isBlocked
virtual bool isBlocked(const std::string &path) const override
Check if a URI path is blocked.
Definition: UriReader.cpp:53
dd4hep::detail::tools::copy
void copy(Alignment from, Alignment to)
Copy alignment object from source object.
Definition: AlignmentTools.cpp:43
dd4hep::xml::UriReader::UserContext
Base class of the user context type chained to the entity resolver.
Definition: UriReader.h:45
dd4hep::xml::UriReader::context
virtual UserContext * context()=0
Access to local context.
dd4hep::xml::UriReader::load
virtual bool load(const std::string &system_id, UserContext *context, std::string &data)=0
Resolve a given URI to a string containing the data with context.