Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-27 09:20:10

0001 /**
0002  *  @file   PandoraSDK/include/Pandora/ExternallyConfiguredAlgorithm.h
0003  *
0004  *  @brief  Header file for the externally configured algorithm class.
0005  *
0006  *  $Log: $
0007  */
0008 #ifndef PANDORA_EXTERNALLY_CONFIGURED_ALGORITHM_H
0009 #define PANDORA_EXTERNALLY_CONFIGURED_ALGORITHM_H 1
0010 
0011 #include "Pandora/Algorithm.h"
0012 
0013 #include <map>
0014 #include <unordered_map>
0015 
0016 namespace pandora
0017 {
0018 
0019 /**
0020  *  @brief  External parameters class
0021  */
0022 class ExternalParameters
0023 {
0024 public:
0025     /**
0026      *  @brief  Default constructor
0027      */
0028     ExternalParameters();
0029 
0030     /**
0031      *  @brief  Destructor
0032      */
0033     virtual ~ExternalParameters();
0034 
0035 private:
0036     /**
0037      *  @brief  Register an attempt to access the external parameters during algorithm configuration
0038      */
0039     void RegisterParameterAccessAttempt();
0040 
0041     unsigned int m_nParameterAccessAttempts;            ///< The number of attempts made to access the external parameters
0042 
0043     friend class ExternallyConfiguredAlgorithm;
0044 };
0045 
0046 //------------------------------------------------------------------------------------------------------------------------------------------
0047 
0048 /**
0049  *  @brief  Externally configured algorithm class. Provides ability for external specification of algorithm-defined parameter blocks.
0050  *          A single call to GetExternalParameters per algorithm type, per Pandora instance is enforced to prevent misuse.
0051  *          In the case of multiple instances of a given algorithm type, must revert to standard xml-based configuration.
0052  */
0053 class ExternallyConfiguredAlgorithm : public Algorithm
0054 {
0055 public:
0056     /**
0057      *  @brief  Destructor
0058      */
0059     virtual ~ExternallyConfiguredAlgorithm();
0060 
0061     /**
0062      *  @brief  Set the external parameters associated with an algorithm instance of a specific type, created by the given Pandora instance
0063      *
0064      *  @param  pandora the pandora instance
0065      *  @param  algorithmType the algorithm type
0066      *  @param  pExternalParameters the address of the external parameters instance
0067      */
0068     static StatusCode SetExternalParameters(const Pandora &pandora, const std::string &algorithmType, ExternalParameters *const pExternalParameters);
0069 
0070 protected:
0071     /**
0072      *  @brief  Whether external parameters are present
0073      *
0074      *  @return boolean
0075      */
0076     bool ExternalParametersPresent() const;
0077 
0078     /**
0079      *  @brief  Get the external parameters associated with algorithm instances created by a given Pandora instance.
0080      *          A single call to this function per algorithm type, per Pandora instance is enforced to prevent misuse.
0081      *
0082      *  @return the address of the external parameters
0083      */
0084     ExternalParameters *GetExternalParameters() const;
0085 
0086 private:
0087     /**
0088      *  @brief  External parameters map class
0089      */
0090     class ExternalParametersMap
0091     {
0092     public:
0093         /**
0094          *  @brief  Destructor
0095          */
0096         ~ExternalParametersMap();
0097 
0098         /**
0099          *  @brief  Whether external parameters are present
0100          *
0101          *  @param  pandora the pandora instance
0102          *  @param  algorithmType the algorithm type
0103          *
0104          *  @return boolean
0105          */
0106         bool ExternalParametersPresent(const pandora::Pandora &pandora, const std::string &algorithmType) const;
0107 
0108         /**
0109          *  @brief  Get the external parameters associated with algorithm instances created by a given Pandora instance.
0110          *          A single call to this function per algorithm type, per Pandora instance is enforced to prevent misuse.
0111          *
0112          *  @param  pandora the pandora instance
0113          *  @param  algorithmType the algorithm type
0114          *
0115          *  @return the address of the external parameters
0116          */
0117         ExternalParameters *GetExternalParameters(const pandora::Pandora &pandora, const std::string &algorithmType) const;
0118 
0119         /**
0120          *  @brief  Set the external parameters associated with an algorithm instance of a specific type, created by the given Pandora instance
0121          *
0122          *  @param  pandora the pandora instance
0123          *  @param  algorithmType the algorithm type
0124          *  @param  pExternalParameters the address of the external parameters instance
0125          */
0126         pandora::StatusCode SetExternalParameters(const pandora::Pandora &pandora, const std::string &algorithmType, ExternalParameters *const pExternalParameters);
0127 
0128         /**
0129          *  @brief  Remove the external parameters associated with an algorithm instance of a specific type, created by the given Pandora instance
0130          *
0131          *  @param  pandora the pandora instance
0132          *  @param  algorithmType the algorithm type
0133          */
0134         void RemoveExternalParameters(const pandora::Pandora &pandora, const std::string &algorithmType);
0135 
0136     private:
0137         typedef std::map<const std::string, ExternalParameters*> AlgTypeToParametersMap;
0138         typedef std::unordered_map<const Pandora*, AlgTypeToParametersMap> TheMap;
0139 
0140         TheMap  m_theMap;   ///< The underlying external parameters map
0141     };
0142 
0143     static ExternalParametersMap m_externalParametersMap;   ///< The external parameters map
0144 };
0145 
0146 } // namespace pandora
0147 
0148 #endif // #ifndef PANDORA_EXTERNALLY_CONFIGURED_ALGORITHM_H