Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/XML/UriReader.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 //==========================================================================
0002 //  AIDA Detector description implementation 
0003 //--------------------------------------------------------------------------
0004 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
0005 // All rights reserved.
0006 //
0007 // For the licensing terms see $DD4hepINSTALL/LICENSE.
0008 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
0009 //
0010 // Author     : M.Frank
0011 //
0012 //==========================================================================
0013 #ifndef XML_URIREADER_H
0014 #define XML_URIREADER_H
0015 
0016 // C/C++ include files
0017 #include <string>
0018 
0019 /// Namespace for the AIDA detector description toolkit
0020 namespace dd4hep {
0021 
0022   /// Namespace containing utilities to parse XML files using XercesC or TinyXML
0023   namespace xml {
0024 
0025     /// Class supporting to read data given a URI
0026     /**
0027      *  Interface to use entity resolvers for parsing layered XML documents
0028      *  Currently only supported by the XercesC interface. 
0029      *  No support for TinyXML possible.
0030      *
0031      *  \author   M.Frank
0032      *  \version  1.0
0033      *  \ingroup DD4HEP_XML
0034      */
0035     class UriReader {
0036     public:
0037       /// Base class of the user context type chained to the entity resolver
0038       /*  User overloaded extensions hole the information necessary 
0039        *  to perform the entity resolution
0040        *  
0041        *  \author   M.Frank
0042        *  \version  1.0
0043        *  \ingroup DD4HEP_XML
0044        */
0045       struct UserContext {
0046         UserContext() = default;
0047         UserContext(const UserContext&) = default;
0048         virtual ~UserContext() = default;
0049       };
0050     public:
0051       /// Default constructor
0052       UriReader()  = default;
0053       /// Default destructor
0054       virtual ~UriReader();
0055       /// Access to local context
0056       virtual UserContext* context() = 0;
0057       /** Helpers for selective parsing  */
0058       /// Add a blocked path entry
0059       virtual void blockPath(const std::string&  /* path */)  {}
0060       /// Check if a URI path is blocked
0061       virtual bool isBlocked(const std::string& /* path */)  const  { return false; }
0062       /// Resolve a given URI to a string containing the data
0063       virtual bool load(const std::string& system_id, std::string& data);
0064       /// Resolve a given URI to a string containing the data with context
0065       virtual bool load(const std::string& system_id, UserContext* context, std::string& data) = 0;
0066       /// Inform reader about a locally (e.g. by XercesC) handled source load
0067       virtual void parserLoaded(const std::string& system_id);
0068       /// Inform reader about a locally (e.g. by XercesC) handled source load
0069       virtual void parserLoaded(const std::string& system_id, UserContext* ctxt) = 0;
0070     };
0071 
0072     /// Class supporting to read data given a URI
0073     /**
0074      *  Wrapper to read XML URI using a virtual reader instance.
0075      *  This implementation allows to externally chain an argument 
0076      *  structure to the resolution function, which allows to set/retrieve
0077      *  further arguments such as e.g. conditions IOVs.
0078      *
0079      *  \author   M.Frank
0080      *  \version  1.0
0081      *  \ingroup DD4HEP_XML
0082      */
0083     class UriContextReader : public UriReader  {
0084     protected:
0085       /// Pointer to true reader object
0086       UriReader* m_reader;
0087       /// Pointer to user context
0088       UriReader::UserContext* m_context;
0089     public:
0090       /// Default initializing constructor
0091       UriContextReader(UriReader* reader, UriReader::UserContext* ctxt);
0092       /// Copy constructor
0093       UriContextReader(const UriContextReader& copy);
0094       /// Default destructor
0095       virtual ~UriContextReader();
0096       /// Access to local context
0097       virtual UserContext* context()  override  {  return m_context;  }
0098       /** Helpers for selective parsing  */
0099       /// Add a blocked path entry
0100       virtual void blockPath(const std::string& path)  override;
0101       /// Check if a URI path is blocked
0102       virtual bool isBlocked(const std::string& path)  const  override;
0103       /// Resolve a given URI to a string containing the data
0104       virtual bool load(const std::string& system_id, std::string& data)  override;
0105       /// Resolve a given URI to a string containing the data with context
0106       virtual bool load(const std::string& system_id, UserContext* context, std::string& data)  override;
0107       /// Inform reader about a locally (e.g. by XercesC) handled source load
0108       virtual void parserLoaded(const std::string& system_id)  override;
0109       /// Inform reader about a locally (e.g. by XercesC) handled source load
0110       virtual void parserLoaded(const std::string& system_id, UserContext* ctxt)  override;
0111     };
0112 
0113   }       /* End namespace xml               */
0114 }         /* End namespace dd4hep            */
0115 #endif // XML_URIREADER_H