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/Process.h
0003  * 
0004  *  @brief  Header file for the process class.
0005  * 
0006  *  $Log: $
0007  */
0008 #ifndef PANDORA_PROCESS_H
0009 #define PANDORA_PROCESS_H 1
0010 
0011 #include "Pandora/StatusCodes.h"
0012 
0013 #include <string>
0014 
0015 namespace pandora
0016 {
0017 
0018 class Pandora;
0019 class TiXmlHandle;
0020 
0021 //------------------------------------------------------------------------------------------------------------------------------------------
0022 
0023 /**
0024  *  @brief  Process class.
0025  */
0026 class Process
0027 {
0028 public:
0029     /**
0030      *  @brief  Default constructor
0031      */
0032     Process();
0033 
0034     /**
0035      *  @brief  Get the type
0036      * 
0037      *  @return The type
0038      */
0039     const std::string &GetType() const;
0040 
0041     /**
0042      *  @brief  Get the instance name
0043      * 
0044      *  @return The instance name
0045      */
0046     const std::string &GetInstanceName() const;
0047 
0048     /**
0049      *  @brief  Get the associated pandora instance
0050      * 
0051      *  @return the associated pandora instance
0052      */
0053     const Pandora &GetPandora() const;
0054 
0055 protected:
0056     /**
0057      *  @brief  Read the algorithm settings
0058      * 
0059      *  @param  xmlHandle the relevant xml handle
0060      */
0061     virtual StatusCode ReadSettings(const TiXmlHandle xmlHandle) = 0;
0062 
0063     /**
0064      *  @brief  Perform any operations that must occur after reading settings, but before running the process
0065      */
0066     virtual StatusCode Initialize();
0067 
0068     /**
0069      *  @brief  Perform any operations when pandora is reset, typically at the end of each event
0070      */
0071     virtual StatusCode Reset();
0072 
0073     /**
0074      *  @brief  Destructor
0075      */
0076     virtual ~Process();
0077 
0078     /**
0079      *  @brief  Register i) the pandora instance that will run the process and ii) the process type
0080      * 
0081      *  @param  pPandora address of the pandora object that will run the process
0082      *  @param  type the process type
0083      *  @param  instanceName the process instance name
0084      */
0085     StatusCode RegisterDetails(const Pandora *const pPandora, const std::string &type, const std::string &instanceName);
0086 
0087     const Pandora          *m_pPandora;             ///< The pandora object that will run the process
0088     std::string             m_type;                 ///< The process type
0089     std::string             m_instanceName;         ///< The process instance name
0090 };
0091 
0092 //------------------------------------------------------------------------------------------------------------------------------------------
0093 //------------------------------------------------------------------------------------------------------------------------------------------
0094 
0095 inline Process::Process() :
0096     m_pPandora(nullptr)
0097 {
0098 }
0099 
0100 //------------------------------------------------------------------------------------------------------------------------------------------
0101 
0102 inline const std::string &Process::GetType() const
0103 {
0104     return m_type;
0105 }
0106 
0107 //------------------------------------------------------------------------------------------------------------------------------------------
0108 
0109 inline const std::string &Process::GetInstanceName() const
0110 {
0111     return m_instanceName;
0112 }
0113 
0114 //------------------------------------------------------------------------------------------------------------------------------------------
0115 
0116 inline const Pandora &Process::GetPandora() const
0117 {
0118     if (!m_pPandora)
0119         throw StatusCodeException(STATUS_CODE_NOT_INITIALIZED);
0120 
0121     return *m_pPandora;
0122 }
0123 
0124 //------------------------------------------------------------------------------------------------------------------------------------------
0125 
0126 inline StatusCode Process::Initialize()
0127 {
0128     return STATUS_CODE_SUCCESS;
0129 }
0130 
0131 //------------------------------------------------------------------------------------------------------------------------------------------
0132 
0133 inline StatusCode Process::Reset()
0134 {
0135     return STATUS_CODE_SUCCESS;
0136 }
0137 
0138 //------------------------------------------------------------------------------------------------------------------------------------------
0139 
0140 inline Process::~Process()
0141 {
0142 }
0143 
0144 //------------------------------------------------------------------------------------------------------------------------------------------
0145 
0146 inline StatusCode Process::RegisterDetails(const Pandora *const pPandora, const std::string &type, const std::string &instanceName)
0147 {
0148     if (!pPandora || type.empty() || instanceName.empty())
0149         return STATUS_CODE_INVALID_PARAMETER;
0150 
0151     if (m_pPandora || !m_type.empty() || !m_instanceName.empty())
0152         return STATUS_CODE_ALREADY_PRESENT;
0153 
0154     m_pPandora = pPandora;
0155     m_type = type;
0156     m_instanceName = instanceName;
0157 
0158     return STATUS_CODE_SUCCESS;
0159 }
0160 
0161 } // namespace pandora
0162 
0163 #endif // #ifndef PANDORA_ALGORITHM_TOOL_H