diff --git a/LCS/Common/include/Common/KVpair.h b/LCS/Common/include/Common/KVpair.h index cd43f459f104b7362abdea5641496d8e72905939..ed504cc64a478d74dde07060485c340d98902df2 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 f53336d629aed83882d873cd1a4cb972195fe7f5..6597391302dab1d65543bc9d9a94eea051cea782 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 123b4f971bbacdd9a281f2c1e941c7f2ac0ed066..b5b7340bf1dcf35a3106717ac4d9e29fff64290f 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 b1d0dab23e63b2e6a4c352a13f242bb7af09d9a2..c55007af0fc5cc1a7d8d7e8a73733306da508b7f 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 4f86437b2a7dce1308a1cc9f07836fc085ec917f..fc36ccbb2e83de9d8ce624ae68bc24bcb9157109 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 68bb5cb2ecc1eb72cfff41bd154dfda1aa0506d7..751f65faba9b6cd5311f0714f0905c6c14f623e4 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 9bcccd49095de1afa2089061f064f72e1b8a1398..7789e548ca554e19b4b90056caa1bf3f880efd3e 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 d5b8f8a67f468c7888f67b7153710652bb2c0ad7..80684eb1c3839a2213b2d8973c5a5bd4440bbc3e 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 db9aa15aa910aac84f21bd682ed2c7be818be6cd..60a47076ca6764c1d429f357f7478a960519b17c 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 68b54b54d494bae35e0cfa939c86ea83b9528f6b..b8485ba26e4b2ca7d6e9a6e721091858ea7bfe83 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())); }