From d69ce59a3fc56619583a04c24e4f61dcd57c74bc Mon Sep 17 00:00:00 2001 From: Alexander van Amesfoort <amesfoort@astron.nl> Date: Thu, 19 Jun 2014 16:36:47 +0000 Subject: [PATCH] Task #5830: revert most KVpair changes. The extra overloads clash on either 32 or 64 bit. Adding overloads will also fail, as they cannot be mapped to PVSS data types in the PVSSGateway (default case there is to try string). So overloads -> template won't work either. Agreed with Ruud to also remove the vector<int> support (already not mapped). Then to solve the original data type problem, adapt a few logged data types from uint or ulong to int. While at it, adapt a few to bool from string ("0" or "1"). --- LCS/Common/include/Common/KVpair.h | 18 ++++---- LCS/Common/src/KVpair.cc | 43 ++----------------- LCS/Common/test/tKVpair.cc | 31 +------------ LCS/Common/test/tKVpair.stdout | 8 ---- MAC/MACIO/src/KVT_Protocol.prot | 12 +++--- RTCP/Cobalt/CoInterface/src/TABTranspose.cc | 2 +- .../src/cuda/Pipelines/CorrelatorPipeline.cc | 2 +- .../GPUProc/src/cuda/Pipelines/Pipeline.cc | 2 +- .../InputProc/src/Station/PacketReader.cc | 4 +- RTCP/Cobalt/OutputProc/src/OutputThread.cc | 2 +- 10 files changed, 26 insertions(+), 98 deletions(-) diff --git a/LCS/Common/include/Common/KVpair.h b/LCS/Common/include/Common/KVpair.h index cd43f459f10..ed504cc64a4 100644 --- a/LCS/Common/include/Common/KVpair.h +++ b/LCS/Common/include/Common/KVpair.h @@ -28,8 +28,7 @@ //# Never #include <config.h> or #include <lofar_config.h> in a header file! //# Includes -#include <Common/lofar_map.h> -#include <Common/lofar_vector.h> +#include <utility> #include <Common/lofar_string.h> #include <Common/LofarTypes.h> @@ -39,19 +38,21 @@ namespace LOFAR { // @{ // Implements a KV pair as a pair<string, string>. -class KVpair : public pair<string, string> +class KVpair : public std::pair<string, string> { public: + // Note: while this class is not PVSS specific, it is mostly (only?) + // used by the PVSSGateway, which uses valueType to map the enum values + // below to PVSS types to query (write). + // If you add types at all without PVSS support, document that below, + // so that PVSS users can avoid them. KVpair(const string& aKey, const string& aValue, bool genTimestamp = false, bool timestampInKeyname = false); KVpair(const string& aKey, const char* aValue, bool genTimestamp = false, bool timestampInKeyname = false); KVpair(const string& aKey, bool aValue, bool genTimestamp = false, bool timestampInKeyname = false); KVpair(const string& aKey, int aValue, bool genTimestamp = false, bool timestampInKeyname = false); - KVpair(const string& aKey, unsigned int aValue, bool genTimestamp = false, bool timestampInKeyname = false); - KVpair(const string& aKey, long aValue, bool genTimestamp = false, bool timestampInKeyname = false); - KVpair(const string& aKey, unsigned long aValue, bool genTimestamp = false, bool timestampInKeyname = false); KVpair(const string& aKey, double aValue, bool genTimestamp = false, bool timestampInKeyname = false); KVpair(const string& aKey, float aValue, bool genTimestamp = false, bool timestampInKeyname = false); - KVpair(const string& aKey, const vector<int>& aValue, bool genTimestamp = false, bool timestampInKeyname = false); + KVpair(const string& aKey, time_t aValue, bool genTimestamp = false, bool timestampInKeyname = false); KVpair(); ~KVpair(); @@ -68,8 +69,7 @@ public: int16 valueType; enum { - VT_UNKNOWN = 0, VT_STRING, VT_BOOL, VT_INT, VT_UINT, VT_LONG, VT_ULONG, VT_DOUBLE, VT_FLOAT, - VT_VECTOR = 0x100 + VT_UNKNOWN = 0, VT_STRING, VT_BOOL, VT_INT, VT_DOUBLE, VT_FLOAT, VT_TIME_T }; }; diff --git a/LCS/Common/src/KVpair.cc b/LCS/Common/src/KVpair.cc index f53336d629a..6597391302d 100644 --- a/LCS/Common/src/KVpair.cc +++ b/LCS/Common/src/KVpair.cc @@ -77,30 +77,6 @@ KVpair::KVpair(const string& aKey, int aValue, bool genTimestamp, bool times OPTIONAL_TIMESTAMP } -KVpair::KVpair(const string& aKey, unsigned int aValue, bool genTimestamp, bool timestampInKeyname) : - pair<string, string> (aKey, formatString("%u", aValue)), - timestamp(0.0), - valueType(VT_UINT) -{ - OPTIONAL_TIMESTAMP -} - -KVpair::KVpair(const string& aKey, long aValue, bool genTimestamp, bool timestampInKeyname) : - pair<string, string> (aKey, formatString("%ld", aValue)), - timestamp(0.0), - valueType(VT_LONG) -{ - OPTIONAL_TIMESTAMP -} - -KVpair::KVpair(const string& aKey, unsigned long aValue, bool genTimestamp, bool timestampInKeyname) : - pair<string, string> (aKey, formatString("%lu", aValue)), - timestamp(0.0), - valueType(VT_ULONG) -{ - OPTIONAL_TIMESTAMP -} - KVpair::KVpair(const string& aKey, double aValue, bool genTimestamp, bool timestampInKeyname) : pair<string, string> (aKey, formatString("%.20lg", aValue)), timestamp(0.0), @@ -117,24 +93,13 @@ KVpair::KVpair(const string& aKey, float aValue, bool genTimestamp, bool time OPTIONAL_TIMESTAMP } -KVpair::KVpair(const string& aKey, const vector<int>& aValue, bool genTimestamp, bool timestampInKeyname) : +KVpair::KVpair(const string& aKey, time_t aValue, bool genTimestamp, bool timestampInKeyname) : + pair<string, string> (aKey, formatString("%ld", aValue)), timestamp(0.0), - valueType(VT_STRING | VT_INT) + valueType(VT_TIME_T) { - uint max = aValue.size(); - string strValue = "["; - for (uint i = 0; i < max; i++) { - strValue += formatString("%d", aValue[i]); - if (i < max-1) { - strValue += ","; - } - } - strValue += "]"; - first = aKey; - second = strValue; - OPTIONAL_TIMESTAMP -} +} KVpair::~KVpair() {} diff --git a/LCS/Common/test/tKVpair.cc b/LCS/Common/test/tKVpair.cc index 123b4f971bb..b5b7340bf1d 100644 --- a/LCS/Common/test/tKVpair.cc +++ b/LCS/Common/test/tKVpair.cc @@ -1,6 +1,6 @@ //# tKVpair.cc: test KVpair class //# -//# Copyright (C) 2011 +//# Copyright (C) 2011, 2014 //# ASTRON (Netherlands Foundation for Research in Astronomy) //# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl //# @@ -47,15 +47,6 @@ int main (int, char* argv[]) KVpair KV3("IntegerValue", 125000); cout << "KV3: " << KV3 << endl; - KVpair KV3u("UIntegerValue", 125000U); - cout << "KV3u: " << KV3u << endl; - - KVpair KV3l("LongValue", 1250000000000L); - cout << "KV3l: " << KV3l << endl; - - KVpair KV3ul("ULongValue", 1250000000000UL); - cout << "KV3ul: " << KV3ul << endl; - double d = 57566757.000125; KVpair KV4("DoubleValue", d); cout << "KV4: " << KV4 << endl; @@ -68,14 +59,6 @@ int main (int, char* argv[]) KVpair KV6("TimeTValue", t); cout << "KV6: " << KV6 << endl; - vector<int> vi; - vi.push_back( 5); - vi.push_back(78); - vi.push_back(32); - vi.push_back(39); - vi.push_back(5003); - KVpair KV7("IntVectorValue", vi); - cout << "KV7: " << KV7 << endl; cout << "\n--- Testing constructors with timestamp ---" << endl; KVpair KVT0("stringValue", string("aap noot mies"), true, true); @@ -90,15 +73,6 @@ int main (int, char* argv[]) KVpair KVT3("IntegerValue", 125000, true, true); cout << ">>>KVT3: " << KVT3 << "<<<" << endl; - KVpair KVT3u("UIntegerValue", 125000U, true, true); - cout << ">>>KVT3u: " << KVT3u << "<<<" << endl; - - KVpair KVT3l("LongValue", 1250000000000L, true, true); - cout << ">>>KVT3l: " << KVT3l << "<<<" << endl; - - KVpair KVT3ul("ULongValue", 1250000000000UL, true, true); - cout << ">>>KVT3ul: " << KVT3ul << "<<<" << endl; - KVpair KVT4("DoubleValue", d, true, true); cout << ">>>KVT4: " << KVT4 << "<<<" << endl; @@ -108,9 +82,6 @@ int main (int, char* argv[]) KVpair KVT6("TimeTValue", t, true, true); cout << ">>>KVT6: " << KVT6 << "<<<" << endl; - KVpair KVT7("IntVectorValue", vi, true, true); - cout << ">>>KVT7: " << KVT7 << "<<<" << endl; - cout << "\n--- Testing copy and assignment operators ---" << endl; KVpair KVT1D(KVT1); ASSERTSTR(KVT1 == KVT1D, "Assignment constructor failed"); diff --git a/LCS/Common/test/tKVpair.stdout b/LCS/Common/test/tKVpair.stdout index b1d0dab23e6..c55007af0fc 100644 --- a/LCS/Common/test/tKVpair.stdout +++ b/LCS/Common/test/tKVpair.stdout @@ -4,26 +4,18 @@ KV0: stringValue=aap noot mies KV1: charPtrValue=wim zus jet KV2: booleanValue=True KV3: IntegerValue=125000 -KV3u: UIntegerValue=125000 -KV3l: LongValue=1250000000000 -KV3ul: ULongValue=1250000000000 KV4: DoubleValue=57566757.000124998391 KV5: FloatValue=5.756676e+07 KV6: TimeTValue=1373614941 -KV7: IntVectorValue=[5,78,32,39,5003] --- Testing constructors with timestamp --- >>>KVT0: stringValue{1373614941.134670019}=aap noot mies<<< >>>KVT1: charPtrValue{1373614941.134690046}=wim zus jet<<< >>>KVT2: booleanValue{1373614941.134704113}=True<<< >>>KVT3: IntegerValue{1373614941.134716988}=125000<<< ->>>KVT3u: UIntegerValue{1373614941.134716988}=125000<<< ->>>KVT3l: LongValue{1373614941.134716988}=1250000000000<<< ->>>KVT3ul: ULongValue{1373614941.134716988}=1250000000000<<< >>>KVT4: DoubleValue{1373614941.134732962}=57566757.000124998391<<< >>>KVT5: FloatValue{1373614941.134749889}=5.756676e+07<<< >>>KVT6: TimeTValue{1373614941.134763002}=1373614941<<< ->>>KVT7: IntVectorValue{1373614941.134780884}=[5,78,32,39,5003]<<< --- Testing copy and assignment operators --- diff --git a/MAC/MACIO/src/KVT_Protocol.prot b/MAC/MACIO/src/KVT_Protocol.prot index 4f86437b2a7..fc36ccbb2e8 100644 --- a/MAC/MACIO/src/KVT_Protocol.prot +++ b/MAC/MACIO/src/KVT_Protocol.prot @@ -31,11 +31,11 @@ include = '<Common/KVpair.h>'; prelude = << PRELUDE_END -// REGISTER (uint obsID, string name); -// REGISTER_ACK (uint obsID, string name); +// REGISTER (uint obsID, std::string name); +// REGISTER_ACK (uint obsID, std::string name); // SEND_MSG (int seqnr, KVpair kvp; // SEND_MSG_ACK (int seqnr, uint result); -// SEND_MSG_POOL (int seqnr, vector<KVpair> kvps); +// SEND_MSG_POOL (int seqnr, std::vector<KVpair> kvps); // SEND_MSG_POOL_ACK(int seqnr, uint result); using LOFAR::operator<<; @@ -57,7 +57,7 @@ event = { }; param = { name = "name"; - type = "string"; + type = "std::string"; }; }; @@ -70,7 +70,7 @@ event = { }; param = { name = "name"; - type = "string"; + type = "std::string"; }; }; @@ -109,7 +109,7 @@ event = { }; param = { name = "kvps"; - type = "vector<KVpair>"; + type = "std::vector<KVpair>"; }; }; diff --git a/RTCP/Cobalt/CoInterface/src/TABTranspose.cc b/RTCP/Cobalt/CoInterface/src/TABTranspose.cc index 68bb5cb2ecc..751f65faba9 100644 --- a/RTCP/Cobalt/CoInterface/src/TABTranspose.cc +++ b/RTCP/Cobalt/CoInterface/src/TABTranspose.cc @@ -707,7 +707,7 @@ void MultiSender::append( SmartPtr<struct Subband> &subband ) } itsMdLogger.log(itsMdKeyPrefix + PN_CGP_DROPPING + '[' + lexical_cast<string>(globalSubbandIdx) + ']', - dropping ? "1" : "0"); + dropping); // Append the data to the respective queue queue->append(subband); diff --git a/RTCP/Cobalt/GPUProc/src/cuda/Pipelines/CorrelatorPipeline.cc b/RTCP/Cobalt/GPUProc/src/cuda/Pipelines/CorrelatorPipeline.cc index 9bcccd49095..7789e548ca5 100644 --- a/RTCP/Cobalt/GPUProc/src/cuda/Pipelines/CorrelatorPipeline.cc +++ b/RTCP/Cobalt/GPUProc/src/cuda/Pipelines/CorrelatorPipeline.cc @@ -174,7 +174,7 @@ namespace LOFAR LOG_DEBUG_STR("[" << id << "] Done"); itsMdLogger.log(itsMdKeyPrefix + PN_CGP_DROPPING + '[' + lexical_cast<string>(globalSubbandIdx) + ']', - droppedBlocks > 0 ? "1" : "0"); + droppedBlocks > 0); itsBlocksDropped += droppedBlocks; itsMdLogger.log(itsMdKeyPrefix + PN_CGP_WRITTEN + '[' + lexical_cast<string>(globalSubbandIdx) + ']', itsBlocksWritten * static_cast<float>(ps.settings.blockDuration())); diff --git a/RTCP/Cobalt/GPUProc/src/cuda/Pipelines/Pipeline.cc b/RTCP/Cobalt/GPUProc/src/cuda/Pipelines/Pipeline.cc index d5b8f8a67f4..80684eb1c38 100644 --- a/RTCP/Cobalt/GPUProc/src/cuda/Pipelines/Pipeline.cc +++ b/RTCP/Cobalt/GPUProc/src/cuda/Pipelines/Pipeline.cc @@ -93,7 +93,7 @@ namespace LOFAR itsMdLogger.log(itsMdKeyPrefix + PN_CGP_OBSERVATION_NAME, boost::lexical_cast<string>(ps.observationID())); for (unsigned i = 0; i < subbandIndices.size(); ++i) { itsMdLogger.log(itsMdKeyPrefix + PN_CGP_SUBBAND + '[' + boost::lexical_cast<string>(subbandIndices[i]) + ']', - subbandIndices[i]); + (int)subbandIndices[i]); } } diff --git a/RTCP/Cobalt/InputProc/src/Station/PacketReader.cc b/RTCP/Cobalt/InputProc/src/Station/PacketReader.cc index db9aa15aa91..60a47076ca6 100644 --- a/RTCP/Cobalt/InputProc/src/Station/PacketReader.cc +++ b/RTCP/Cobalt/InputProc/src/Station/PacketReader.cc @@ -187,10 +187,10 @@ namespace LOFAR // Reproduce PN_CSI_STREAM0_BLOCKS_IN or PN_CSI_STREAM0_REJECTED, but with the right nr. string streamStr = str(boost::format("stream%u") % boardNr); mdLogger.log(mdKeyPrefix + streamStr + ".blocksIn", - (unsigned)round(nrReceived / interval)); + (int)round(nrReceived / interval)); size_t nrBad = nrBadTime + nrBadMode + nrBadData + nrBadOther; mdLogger.log(mdKeyPrefix + streamStr + ".rejected", - (unsigned)round(nrBad / interval)); + (int)round(nrBad / interval)); // Reset counters nrReceived = 0; diff --git a/RTCP/Cobalt/OutputProc/src/OutputThread.cc b/RTCP/Cobalt/OutputProc/src/OutputThread.cc index 68b54b54d49..b8485ba26e4 100644 --- a/RTCP/Cobalt/OutputProc/src/OutputThread.cc +++ b/RTCP/Cobalt/OutputProc/src/OutputThread.cc @@ -151,7 +151,7 @@ namespace LOFAR itsBlocksWritten++; itsMdLogger.log(itsMdKeyPrefix + PN_COP_DROPPING + '[' + lexical_cast<string>(itsStreamNr) + ']', - droppedBlocks > 0 ? "1" : "0"); // logged too late if dropping: not anymore... + droppedBlocks > 0); // logged too late if dropping: not anymore... itsMdLogger.log(itsMdKeyPrefix + PN_COP_WRITTEN + '[' + lexical_cast<string>(itsStreamNr) + ']', itsBlocksWritten * static_cast<float>(itsParset.settings.blockDuration())); } -- GitLab