]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliDCSValue.cxx
added HOMER library from PubSub package HLT-stable-20070905.141318 (rev. 2375)
[u/mrichter/AliRoot.git] / STEER / AliDCSValue.cxx
index 225d7220db46313293c68fe81a7d83b0b56a151b..fc8bad2ee1fb03ef625dcb2da1408b8350eef22d 100644 (file)
 
 /*
 $Log$
+Revision 1.4  2006/09/04 17:42:34  hristov
+Changes required by Effective C++
+
+Revision 1.3  2006/07/20 09:43:46  jgrosseo
+removing dynamic types
+
+Revision 1.2  2006/07/04 14:58:11  jgrosseo
+revision of AliDCSValue: Removed wrapper classes, reduced storage size per value by factor 2
+
 Revision 1.1  2006/06/02 14:14:36  hristov
 Separate library for CDB (Jan)
 
@@ -53,62 +62,80 @@ some more descriptions added
 
 ClassImp(AliDCSValue)
 
-AliDCSValue::AliDCSValue() : TObject()
+AliDCSValue::AliDCSValue() :
+  TObject(),
+  fType(kInvalid),
+  fBool(kFALSE),
+  fChar(0),
+  fInt(0),
+  fUInt(0),
+  fFloat(0),
+  fTimeStamp(0)
 {
   // default constructor
-
-  Init();
 }
 
-AliDCSValue::AliDCSValue(Bool_t value, UInt_t timeStamp) : TObject()
+AliDCSValue::AliDCSValue(Bool_t value, UInt_t timeStamp) : 
+  TObject(),
+  fType(kBool),
+  fBool(value),
+  fChar(0),
+  fInt(0),
+  fUInt(0),
+  fFloat(0),
+  fTimeStamp(timeStamp)
 {
   // constructor
-
-  Init();
-
-  fTimeStamp = timeStamp;
-
-  fType = kBool;
-  fBool = value;
 }
 
-AliDCSValue::AliDCSValue(Char_t value, UInt_t timeStamp) : TObject()
+AliDCSValue::AliDCSValue(Char_t value, UInt_t timeStamp) :
+  TObject(),
+  fType(kChar),
+  fBool(kFALSE),
+  fChar(value),
+  fInt(0),
+  fUInt(0),
+  fFloat(0),
+  fTimeStamp(timeStamp)
 {
   // constructor
-
-  Init();
-
-  fTimeStamp = timeStamp;
-
-  fType = kChar;
-  fChar = value;
 }
 
-AliDCSValue::AliDCSValue(Int_t value, UInt_t timeStamp) : TObject()
+AliDCSValue::AliDCSValue(Int_t value, UInt_t timeStamp) :
+  TObject(),
+  fType(kInt),
+  fBool(kFALSE),
+  fChar(0),
+  fInt(value),
+  fUInt(0),
+  fFloat(0),
+  fTimeStamp(timeStamp)
 {
   // constructor
-
-  Init();
-
-  fTimeStamp = timeStamp;
-
-  fType = kInt;
-  fInt = value;
 }
 
-AliDCSValue::AliDCSValue(UInt_t value, UInt_t timeStamp) : TObject()
+AliDCSValue::AliDCSValue(UInt_t value, UInt_t timeStamp) :
+  TObject(),
+  fType(kUInt),
+  fBool(kFALSE),
+  fChar(0),
+  fInt(0),
+  fUInt(value),
+  fFloat(0),
+  fTimeStamp(timeStamp)
 {
   // constructor
-
-  Init();
-
-  fTimeStamp = timeStamp;
-
-  fType = kUInt;
-  fUInt = value;
 }
 
-AliDCSValue::AliDCSValue(Float_t value, UInt_t timeStamp) : TObject()
+AliDCSValue::AliDCSValue(Float_t value, UInt_t timeStamp) :
+  TObject(),
+  fType(kFloat),
+  fBool(kFALSE),
+  fChar(0),
+  fInt(0),
+  fUInt(0),
+  fFloat(value),
+  fTimeStamp(timeStamp)
 {
   // constructor
 
@@ -120,76 +147,17 @@ AliDCSValue::AliDCSValue(Float_t value, UInt_t timeStamp) : TObject()
   fFloat = value;
 }
 
-AliDCSValue::AliDCSValue(Int_t size, Bool_t* vals, UInt_t timeStamp) : TObject()
-{
-  // constructor
-
-  Init();
-
-  fTimeStamp = timeStamp;
-
-  fType = kDynBool;
-  fBoolPtr = vals;
-  fLength = size;
-}
-
-AliDCSValue::AliDCSValue(Int_t size, Char_t* vals, UInt_t timeStamp) : TObject()
-{
-  // constructor
-
-  Init();
-
-  fTimeStamp = timeStamp;
-
-  fType = kDynChar;
-  fCharPtr = vals;
-  fLength = size;
-}
-
-AliDCSValue::AliDCSValue(Int_t size, Int_t* vals, UInt_t timeStamp) : TObject()
-{
-  // constructor
-
-  Init();
-
-  fTimeStamp = timeStamp;
-
-  fType = kDynInt;
-  fIntPtr = vals;
-  fLength = size;
-}
-
-AliDCSValue::AliDCSValue(Int_t size, UInt_t* vals, UInt_t timeStamp) : TObject()
-{
-  // constructor
-
-  Init();
-
-  fTimeStamp = timeStamp;
-
-  fType = kDynUInt;
-  fUIntPtr = vals;
-  fLength = size;
-}
-
-AliDCSValue::AliDCSValue(Int_t size, Float_t* vals, UInt_t timeStamp) : TObject()
-{
-  // constructor
-
-  Init();
-
-  fTimeStamp = timeStamp;
-
-  fType = kDynFloat;
-  fFloatPtr = vals;
-  fLength = size;
-}
-
-AliDCSValue::AliDCSValue(const AliDCSValue& c) : TObject(c)
+AliDCSValue::AliDCSValue(const AliDCSValue& c) :
+  TObject(c),
+  fType(c.fType),
+  fBool(c.fBool),
+  fChar(c.fChar),
+  fInt(c.fInt),
+  fUInt(c.fUInt),
+  fFloat(c.fFloat),
+  fTimeStamp(c.fTimeStamp)
 {
   // copy constructor
-
-  ((AliDCSValue &)c).Copy(*this);
 }
 
 void AliDCSValue::Init()
@@ -204,50 +172,12 @@ void AliDCSValue::Init()
   fUInt = 0;
   fFloat = 0;
 
-  fLength = 0;
-
-  fBoolPtr = 0;
-  fCharPtr = 0;
-  fIntPtr = 0;
-  fUIntPtr = 0;
-  fFloatPtr = 0;
-
   fTimeStamp = 0;
 }
 
 AliDCSValue::~AliDCSValue()
 {
   // destructor
-
-  if (fBoolPtr)
-  {
-    delete[] fBoolPtr;
-    fBoolPtr = 0;
-  }
-
-  if (fCharPtr)
-  {
-    delete[] fCharPtr;
-    fCharPtr = 0;
-  }
-
-  if (fIntPtr)
-  {
-    delete[] fIntPtr;
-    fIntPtr = 0;
-  }
-
-  if (fUIntPtr)
-  {
-    delete[] fUIntPtr;
-    fUIntPtr = 0;
-  }
-
-  if (fFloatPtr)
-  {
-    delete[] fFloatPtr;
-    fFloatPtr = 0;
-  }
 }
 
 AliDCSValue &AliDCSValue::operator=(const AliDCSValue &c)
@@ -276,42 +206,6 @@ void AliDCSValue::Copy(TObject& c) const
   target.fUInt = fUInt;
   target.fFloat = fFloat;
 
-  target.fLength = fLength;
-
-  if (fLength > 0)
-  {
-    if (fBoolPtr)
-    {
-      target.fBoolPtr = new Bool_t[fLength];
-      for (UInt_t i=0; i<fLength; ++i)
-        target.fBoolPtr[i] = fBoolPtr[i];
-    }
-    if (fCharPtr)
-    {
-      target.fCharPtr = new Char_t[fLength];
-      for (UInt_t i=0; i<fLength; ++i)
-        target.fCharPtr[i] = fCharPtr[i];
-    }
-    if (fIntPtr)
-    {
-      target.fIntPtr = new Int_t[fLength];
-      for (UInt_t i=0; i<fLength; ++i)
-        target.fIntPtr[i] = fIntPtr[i];
-    }
-    if (fUIntPtr)
-    {
-      target.fUIntPtr = new UInt_t[fLength];
-      for (UInt_t i=0; i<fLength; ++i)
-        target.fUIntPtr[i] = fUIntPtr[i];
-    }
-    if (fFloatPtr)
-    {
-      target.fFloatPtr = new Float_t[fLength];
-      for (UInt_t i=0; i<fLength; ++i)
-        target.fFloatPtr[i] = fFloatPtr[i];
-    }
-  }
-
   target.fTimeStamp = fTimeStamp;
 }
 
@@ -329,54 +223,31 @@ Int_t AliDCSValue::GetSize() const
     case kUInt:  size += sizeof(UInt_t);  break;
     case kFloat: size += sizeof(Float_t); break;
 
-    case kDynBool:  size += fLength * sizeof(Bool_t);   break;
-    case kDynChar:  size += fLength * sizeof(Char_t);   break;
-    case kDynInt:   size += fLength * sizeof(Int_t);    break;
-    case kDynUInt:  size += fLength * sizeof(UInt_t);   break;
-    case kDynFloat: size += fLength * sizeof(Float_t);  break;
-
     case kInvalid: break;
   }
 
   return size;
 }
 
-Bool_t AliDCSValue::IsDynamic(Type type)
-{
-  // return if the given type is dynamic
-
-  switch (type)
-  {
-    case kDynBool:
-    case kDynChar:
-    case kDynInt:
-    case kDynUInt:
-    case kDynFloat: return kTRUE; break;
-
-    default: return kFALSE; break;
-  }
-}
-
 const Char_t* AliDCSValue::ToString() const
 {
   TString str;
 
   switch (fType)
   {
-    case kBool:  str.Form("%d", fBool);  break;
+    case kBool:  str = (fBool == kFALSE) ? "FALSE" : "TRUE"; break;
     case kChar:  str.Form("%d", fChar);  break;
     case kInt:   str.Form("%d", fInt);  break;
     case kUInt:  str.Form("%d", fUInt);  break;
     case kFloat: str.Form("%f", fFloat);  break;
 
-    case kDynBool:  for (UInt_t i=0; i<fLength; ++i) str += Form("%d ", fBoolPtr[i]); break;
-    case kDynChar:  for (UInt_t i=0; i<fLength; ++i) str += Form("%d ", fCharPtr[i]); break;
-    case kDynInt:   for (UInt_t i=0; i<fLength; ++i) str += Form("%d ", fIntPtr[i]); break;
-    case kDynUInt:  for (UInt_t i=0; i<fLength; ++i) str += Form("%d ", fUIntPtr[i]); break;
-    case kDynFloat: for (UInt_t i=0; i<fLength; ++i) str += Form("%f ", fFloatPtr[i]); break;
-
     case kInvalid: break;
   }
 
   return Form("%s Timestamp: %s", str.Data(), TTimeStamp(fTimeStamp).AsString());
 }
+
+void AliDCSValue::Print(Option_t* /*opt*/) const
+{
+  printf("%s\n", ToString());
+}