]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/BASE/AliHLTDimServer.h
#97492 Request to: patch AliSimulation; port to Release; make tag on release; for...
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTDimServer.h
index 43c900fdd2a94ba8a484a72fbc5f73b6d11a0476..f6cb2e2684fe4e2accb3f111b77d647c0801c971 100644 (file)
@@ -8,11 +8,12 @@
 //* ALICE Experiment at CERN, All rights reserved.                         *
 //* See cxx source for full Copyright notice                               *
 
-/** @file   AliHLTDimServer.h
-    @author Matthias Richter
-    @date   20010-03-10
-    @brief  HLT DIM server
-*/
+//  @file   AliHLTDimServer.h
+//  @author Matthias Richter
+//  @date   20010-03-10
+//  @brief  HLT DIM server implementation and dynamic access
+//          to DIM library
+
 #include "AliHLTLogging.h"
 #include "TNamed.h"
 #include "TObjArray.h"
@@ -33,6 +34,7 @@ public:
   /// Data type identifiers for services.
   enum AliHLTDimServiceDataType{
     kDataTypeUnknown = 0, /// initializer
+    kDataTypeCustom,      /// Custom format maintained by the user.
     kDataTypeInt,         /// Integer type
     kDataTypeFloat,       /// Float type
     kDataTypeString,      /// String type
@@ -53,17 +55,66 @@ public:
   class AliHLTDimService : public TNamed {
   public:
     AliHLTDimService();
+    
+    /**
+     * Create a new service with a particular predefined type and name.
+     * \param type  The type of the service
+     * \param servicename  The name of the service.
+     */
     AliHLTDimService(AliHLTDimServiceDataType type, const char* servicename);
     
-    void Update(AliHLTDimServicePoint_t& sp);
+    /**
+     * Create a new service with a particular custom type.
+     * \param type  The type of the service as a string.
+     *      The format parameter specifies the contents of the structure in the
+     *      form T:N[;T:N]*[;T] where T is the item type: (I)nteger, (C)arachter,
+     *      (L)ong, (S)hort, (F)loat, (D)ouble, X(tra long) and N is the number
+     *      of such items. The type alone at the end means all following items
+     *      are of the same type. Example: "I:3;F:2;C" means 3 Integers, 2 Floats
+     *      and Characters until the end. The format parameter is used for
+     *      communicating between different platforms.
+     * \param data  Points to a buffer maintained by the user which stores the
+     *      data to publish. This buffer must exist as long as the DIM service
+     *      is registered and active.
+     * \param size  The size of the data structure pointed to by data.
+     * \param servicename  The name of the service.
+     */
+    AliHLTDimService(const char* type, void* data, int size, const char* servicename);
+    
+    /**
+     * Updates the DIM data point for custom data structures.
+     * i.e. This method should be used if the service was created with:
+     * AliHLTDimService(const char* type, void* data, int size, const char* servicename)
+     */
+    void Update();
+    
+    /**
+     * Updates the DIM data point.
+     * This method should be used if the service was created with:
+     * AliHLTDimService(AliHLTDimServiceDataType type, const char* servicename)
+     * \param sp  The new data point to publish via DIM.
+     */
+    void Update(const AliHLTDimServicePoint_t& sp);
+    
     AliHLTDimServiceDataType GetType() const {return fType;}
-    void* GetLocation() {return &fData.iVal;}
+    const char* GetTypeString() const { return fTypeString.Data(); }
+    void* GetLocation() {return fDataBuffer;}
     int GetId() const {return fId;}
     int SetId(int id) {fId=id;return id;}
+    void* GetDataBuffer() const { return fDataBuffer; }
+    int GetDataSize() const { return fDataSize; }
 
   private:
+          
+    // Do not allow copying of this class
+    AliHLTDimService(const AliHLTDimService&);
+    AliHLTDimService& operator = (const AliHLTDimService&);
+          
     AliHLTDimServicePoint_t fData; /// the data point
     AliHLTDimServiceDataType fType; /// type of this service
+    TString fTypeString;  /// The string representing the service type.
+    void* fDataBuffer;  /// Pointer to the data buffer.
+    int fDataSize;  /// The size of the data buffer.
     int fId; /// id of the service
   };
 
@@ -80,10 +131,22 @@ public:
     }
   };
 
+  /** @class AliHLTDimServiceInt
+   * DIM service for a int value
+   */
+  class AliHLTDimServiceInt : public AliHLTDimService {
+  public:
+    AliHLTDimServiceInt();
+    ~AliHLTDimServiceInt();
+
+    void Update(int i) {
+      AliHLTDimServicePoint_t sp; sp.iVal=i; AliHLTDimService::Update(sp);
+    }
+  };
+
   /**
    * Register a service.
    * @param pService    the service to be registered
-   * @ingroup rcu_ce_base_services
    */
   int RegisterService(AliHLTDimService* pService);
 
@@ -92,7 +155,6 @@ public:
    * @param type        type of the channel, see @ref ceServiceDataType
    * @param name        unique name of the service
    * @return dim service object, needs to be cleaned by the caller
-   * @ingroup rcu_ce_base_services
    */
   AliHLTDimService* CreateService(AliHLTDimServiceDataType type, const char* name);
 
@@ -104,7 +166,6 @@ public:
    *                    replaced by the number, number is appended if no '%d' provided
    * @param count       number of services in this group, passed to the <i>update</i> and <i>set</i> function as parameter major
    * @return            TObjArray of AliHLTDimService objects, the array needs to be cleaned by the caller
-   * @ingroup rcu_ce_base_services
    */
   TObjArray* CreateServiceGroup(AliHLTDimServiceDataType type, const char* basename, int count);
 
@@ -141,7 +202,7 @@ protected:
 
   int SetState(int state) {fState=state; return fState;}
 
-  int GetState() {return fState;}
+  int GetState() const {return fState;}
 
   typedef void (*fctVoid)();
   typedef int (*fctDisServiceCallback)( const char*);
@@ -169,37 +230,37 @@ protected:
     int Init();
 
     int DisAddService(const char* service, const char* type, void* buffer, 
-                     int size, fctDisServiceCallback cb, long int tag) {
+                     int size, fctDisServiceCallback cb, long int tag) const {
       if (fpDisAddService) return (*fpDisAddService)(service, type, buffer, size, cb, tag);
       return -ENODEV;
     }
 
-    int DisAddService(const char* service, const char* type, void* buffer, int size) {
+    int DisAddService(const char* service, const char* type, void* buffer, int size) const {
       if (fpDisAddService) return (*fpDisAddService)(service, type, buffer, size, NULL, 0);
       return -ENODEV;
     }
 
-    int DisRemoveService(unsigned int id) {
+    int DisRemoveService(unsigned int id) const {
       if (fpDisRemoveService) return (*fpDisRemoveService)(id);
       return -ENODEV;
     }
 
-    int DisUpdateService(unsigned int id) {
+    int DisUpdateService(unsigned int id) const {
       if (fpDisUpdateService) return (*fpDisUpdateService)(id);
       return -ENODEV;
     }
 
-    int DisStartServing(const char *server) {
+    int DisStartServing(const char *server) const {
       if (fpDisStartServing) return (*fpDisStartServing)(server);
       return -ENODEV;
     }
 
-    int DisStopServing() {
+    int DisStopServing() const {
       if (fpDisStopServing) return (*fpDisStopServing)();
       return -ENODEV;
     }
 
-    int DisSetDnsNode(const char *server) {
+    int DisSetDnsNode(const char *server) const {
       if (fpDisSetDnsNode) return (*fpDisSetDnsNode)(server);
       return -ENODEV;
     }