From ec5c3ac7be6d04a658679ef94d71e4de95f3b133 Mon Sep 17 00:00:00 2001 From: mfasel Date: Wed, 12 Nov 2014 16:04:47 +0100 Subject: [PATCH] - Derive value types from TObject so that they can be used in CINT - Implement ostream operators --- PWG/EMCAL/AliEMCALConfiguration.cxx | 14 ++++++++++++++ PWG/EMCAL/AliEMCALConfiguration.h | 3 +++ PWG/EMCAL/AliEMCALConfigurationObject.cxx | 18 ++++++++++++++++++ PWG/EMCAL/AliEMCALConfigurationObject.h | 20 +++++++++++++++++++- PWG/PWGEMCALLinkDef.h | 7 +++++++ 5 files changed, 61 insertions(+), 1 deletion(-) diff --git a/PWG/EMCAL/AliEMCALConfiguration.cxx b/PWG/EMCAL/AliEMCALConfiguration.cxx index 8cc8fdd5a94..979b4fb4ac9 100644 --- a/PWG/EMCAL/AliEMCALConfiguration.cxx +++ b/PWG/EMCAL/AliEMCALConfiguration.cxx @@ -4,7 +4,9 @@ * Created on: 06.11.2014 * Author: markusfasel */ +#include #include +#include #include #include "AliEMCALJSONReader.h" @@ -82,4 +84,16 @@ const char* AliEMCALConfiguration::CreateJSONString() const { } jsonbuilder << "}"; return jsonbuilder.str().c_str(); +/* + std::cout << "My json string " << jsonbuilder.str().c_str() << std::endl; + char * result = new char[jsonbuilder.str().length()]; + strcpy(result, jsonbuilder.str().c_str()); + return result; +*/ + +} + +std::ostream &operator<<(std::ostream & os, const AliEMCALConfiguration &conf){ + os << conf.CreateJSONString(); + return os; } diff --git a/PWG/EMCAL/AliEMCALConfiguration.h b/PWG/EMCAL/AliEMCALConfiguration.h index f0a1a7e49a6..223f7a24d2a 100644 --- a/PWG/EMCAL/AliEMCALConfiguration.h +++ b/PWG/EMCAL/AliEMCALConfiguration.h @@ -8,6 +8,7 @@ #ifndef PWG_EMCAL_ALIEMCALCONFIGURATION_H_ #define PWG_EMCAL_ALIEMCALCONFIGURATION_H_ +#include #include class TList; @@ -35,4 +36,6 @@ private: ClassDef(AliEMCALConfiguration, 1); }; +std::ostream &operator<<(std::ostream &, const AliEMCALConfiguration &); + #endif /* PWG_EMCAL_ALIEMCALCONFIGURATION_H_ */ diff --git a/PWG/EMCAL/AliEMCALConfigurationObject.cxx b/PWG/EMCAL/AliEMCALConfigurationObject.cxx index 2a0c11f14f3..7cd68a8f0a3 100644 --- a/PWG/EMCAL/AliEMCALConfigurationObject.cxx +++ b/PWG/EMCAL/AliEMCALConfigurationObject.cxx @@ -9,6 +9,13 @@ #include +ClassImp(AliEMCALConfigurationValue) +ClassImp(AliEMCALConfigurationValueInt) +ClassImp(AliEMCALConfigurationValueFloat) +ClassImp(AliEMCALConfigurationValueDouble) +ClassImp(AliEMCALConfigurationValueBool) +ClassImp(AliEMCALConfigurationValueString) +ClassImp(AliEMCALConfigurationObject) const char* AliEMCALConfigurationValueInt::ToString() const { std::stringstream stringbuilder; @@ -51,3 +58,14 @@ const char* AliEMCALConfigurationObject::ToString() const { jsonbuilder << "\"" << GetName() << "\":\"" << fValue->ToString() << "\""; return jsonbuilder.str().c_str(); } + +std::ostream &operator<<(std::ostream &os, const AliEMCALConfigurationValue &val){ + os << val.ToString(); + return os; +} + +std::ostream &operator<<(std::ostream &os, const AliEMCALConfigurationObject &obj){ + os << obj.ToString(); + return os; +} + diff --git a/PWG/EMCAL/AliEMCALConfigurationObject.h b/PWG/EMCAL/AliEMCALConfigurationObject.h index b64c614282c..10b8554edea 100644 --- a/PWG/EMCAL/AliEMCALConfigurationObject.h +++ b/PWG/EMCAL/AliEMCALConfigurationObject.h @@ -8,14 +8,17 @@ #ifndef PWG_EMCAL_ALIEMCALCONFIGURATIONOBJECT_H_ #define PWG_EMCAL_ALIEMCALCONFIGURATIONOBJECT_H_ +#include #include -class AliEMCALConfigurationValue { +class AliEMCALConfigurationValue : public TObject { public: AliEMCALConfigurationValue() {} virtual ~AliEMCALConfigurationValue() {} virtual const char *ToString() const = 0; + + ClassDef(AliEMCALConfigurationValue,1); }; class AliEMCALConfigurationValueInt : public AliEMCALConfigurationValue{ @@ -32,6 +35,8 @@ public: virtual const char *ToString() const ; private: Int_t fValue; + + ClassDef(AliEMCALConfigurationValueInt,1); }; class AliEMCALConfigurationValueFloat : public AliEMCALConfigurationValue{ @@ -48,6 +53,8 @@ public: virtual const char *ToString() const; private: Float_t fValue; + + ClassDef(AliEMCALConfigurationValueFloat,1); }; class AliEMCALConfigurationValueDouble : public AliEMCALConfigurationValue{ @@ -64,6 +71,8 @@ public: virtual const char *ToString() const; private: Double_t fValue; + + ClassDef(AliEMCALConfigurationValueDouble,1); }; class AliEMCALConfigurationValueBool : public AliEMCALConfigurationValue{ @@ -80,6 +89,8 @@ public: virtual const char *ToString() const { return fValue ? "true" : "false"; } private: Bool_t fValue; + + ClassDef(AliEMCALConfigurationValueBool,1); }; class AliEMCALConfigurationValueString : public AliEMCALConfigurationValue{ @@ -96,6 +107,8 @@ public: virtual const char *ToString() const { return fValue; } private: TString fValue; + + ClassDef(AliEMCALConfigurationValueString,1); }; class AliEMCALConfigurationObject : public TNamed { @@ -123,6 +136,11 @@ protected: AliEMCALConfigurationObject &operator=(const AliEMCALConfigurationObject &ref); AliEMCALConfigurationValue *fValue; + + ClassDef(AliEMCALConfigurationObject, 1); }; +std::ostream &operator<<(std::ostream &, const AliEMCALConfigurationValue &); +std::ostream &operator<<(std::ostream &, const AliEMCALConfigurationObject &); + #endif /* PWG_EMCAL_ALIEMCALCONFIGURATIONOBJECT_H_ */ diff --git a/PWG/PWGEMCALLinkDef.h b/PWG/PWGEMCALLinkDef.h index 303997a8f55..ad5e6c3a4eb 100644 --- a/PWG/PWGEMCALLinkDef.h +++ b/PWG/PWGEMCALLinkDef.h @@ -38,6 +38,13 @@ #pragma link C++ class AliEMCALJSONReader+; #pragma link C++ class AliEMCALConfiguration+; #pragma link C++ class AliEMCALConfigHandler+; +#pragma link C++ class AliEMCALConfigurationObject+; +#pragma link C++ class AliEMCALConfigurationValue+; +#pragma link C++ class AliEMCALConfigurationValueInt+; +#pragma link C++ class AliEMCALConfigurationValueFloat+; +#pragma link C++ class AliEMCALConfigurationValueDouble+; +#pragma link C++ class AliEMCALConfigurationValueBool+; +#pragma link C++ class AliEMCALConfigurationValueString+; #endif -- 2.43.0