//* 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"
/// 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
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
};
}
};
+ /** @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);
* @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);
* 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);
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*);
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;
}