Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-06-02 08:51:49

0001 #ifndef SERVICE_OBJECT_H
0002 #define SERVICE_OBJECT_H
0003 
0004 /**
0005  * @file ServiceObject.h
0006  * @author Bryan BERTHOU (SPhN / CEA Saclay)
0007  * @date July 01, 2015
0008  * @version 1.0
0009  */
0010 
0011 #include <ElementaryUtils/parameters/Parameters.h>
0012 #include <ElementaryUtils/thread/Packet.h>
0013 #include <string>
0014 
0015 #include "beans/gpd/GPDType.h"
0016 #include "beans/collinear_distribution/CollinearDistributionType.h"
0017 #include "beans/List.h"
0018 #include "utils/thread/ThreadManager.h"
0019 #include "utils/thread/ThreadQueue.h"
0020 
0021 namespace PARTONS {
0022 class AutomationService;
0023 class ModuleObjectFactory;
0024 class Task;
0025 } /* namespace PARTONS */
0026 
0027 namespace PARTONS {
0028 
0029 /**
0030  * @class ServiceObject
0031  *
0032  * @brief Services hide the complexity of low-level functions to provide high-level functionalities to the user.
0033  *
0034  * A service is basically a toolbox for the user: the user is being given tools to use the software without knowing the details of its operating.
0035  * Services combine different modules and datasets to produce results in a transparent way.
0036  *
0037  * For example : the GPDService provide several functions that hide the complexity related to repetitive tasks,
0038  * like evaluating a GPD at a list of kinematic configurations, or evaluating several GPD models at the same input kinematic.
0039  */
0040 class ServiceObject: public BaseObject {
0041 
0042 public:
0043     /**
0044      * Default constructor.
0045      *
0046      * @param className
0047      */
0048     ServiceObject(const std::string &className);
0049 
0050     /**
0051      * Default destructor.
0052      */
0053     virtual ~ServiceObject();
0054 
0055     virtual void resolveObjectDependencies();
0056 
0057     /**
0058      * Method used in automation to compute given tasks.
0059      * Implemented in child classes.
0060      * @param task Automation task to compute.
0061      */
0062     virtual void computeTask(Task &task) = 0;
0063 
0064     /**
0065      * Add task to queue.
0066      */
0067     void addTasks(const List<ElemUtils::Packet> &tasks);
0068 
0069     /**
0070      * Check if queue is empty.
0071      */
0072     bool isEmptyTaskQueue();
0073 
0074     /**
0075      * Pop task from queue.
0076      */
0077     ElemUtils::Packet popTaskFormQueue();
0078 
0079     /**
0080      * Initialize all threads.
0081      */
0082     void initComputationalThread(ModuleObject* pModuleObject);
0083 
0084     /**
0085      * Lunch all threads.
0086      */
0087     void launchAllThreadAndWaitingFor();
0088 
0089     /**
0090      * Clear all threads.
0091      */
0092     void clearAllThread();
0093 
0094 protected:
0095 
0096     ModuleObjectFactory* m_pModuleObjectFactory; ///< Pointer to ModuleObjectFactory.
0097     AutomationService* m_pAutomationService; ///< Pointer to AutomationService.
0098 
0099     /**
0100      * Get list of GPD types to be computed from a task.
0101      */
0102     List<GPDType> getGPDTypeListFromTask(Task &task) const;
0103 
0104     /**
0105      * Get list of Collinear Distribution types to be computed from a task.
0106      */
0107     List<CollinearDistributionType> getCollinearDistributionTypeListFromTask(Task &task) const;
0108 
0109     /**
0110      * Throw exception if unknown method.
0111      */
0112     void errorUnknownMethod(const Task &task) const;
0113 
0114 private:
0115 
0116     ThreadQueue m_queueOfTask; ///< Queue of tasks.
0117     ThreadManager m_threadManager; ///< Thread manager.
0118 };
0119 
0120 } /* namespace PARTONS */
0121 
0122 #endif /* SERVICE_OBJECT_H */