DP3
KVpair.h
Go to the documentation of this file.
1 // KVpair.h: Implements a KV pair as a pair<string, string>.
2 //
3 // Copyright (C) 2020 ASTRON (Netherlands Institute for Radio Astronomy)
4 // SPDX-License-Identifier: GPL-3.0-or-later
5 
6 #ifndef LOFAR_COMMON_KVPAIR_H
7 #define LOFAR_COMMON_KVPAIR_H
8 
9 // Never #include <config.h> or #include <lofar_config.h> in a header file!
10 #include <ctime>
11 #include <utility>
12 #include <iosfwd>
13 #include <string>
14 
15 namespace dp3 {
16 namespace common {
17 
20 
22 
24 class KVpair : public std::pair<std::string, std::string> {
25  public:
26  // Note: while this class is not PVSS specific, it is mostly (only?)
27  // used by the PVSSGateway, which uses valueType to map the enum values
28  // below to PVSS types to query (write).
29  // If you add types at all without PVSS support, document that below,
30  // so that PVSS users can avoid them.
31  KVpair(const std::string& aKey, const std::string& aValue,
32  bool genTimestamp = false, bool timestampInKeyname = false);
33  KVpair(const std::string& aKey, const char* aValue, bool genTimestamp = false,
34  bool timestampInKeyname = false);
35  KVpair(const std::string& aKey, bool aValue, bool genTimestamp = false,
36  bool timestampInKeyname = false);
37  KVpair(const std::string& aKey, int aValue, bool genTimestamp = false,
38  bool timestampInKeyname = false);
39  KVpair(const std::string& aKey, double aValue, bool genTimestamp = false,
40  bool timestampInKeyname = false);
41  KVpair(const std::string& aKey, float aValue, bool genTimestamp = false,
42  bool timestampInKeyname = false);
43  KVpair(const std::string& aKey, time_t aValue, bool genTimestamp = false,
44  bool timestampInKeyname = false);
45 
46  KVpair();
48 
49  // Copying is allowed
50  KVpair(const KVpair& that);
51  KVpair& operator=(const KVpair& that);
52  inline bool operator==(const KVpair& that) const {
53  return (first == that.first && second == that.second &&
54  timestamp == that.timestamp && valueType == that.valueType);
55  }
56 
57  // data-members
58  double timestamp; // store also as double
59  int16_t valueType;
60 
61  enum {
68  VT_TIME_T
69  };
70 };
71 
73 
74 std::ostream& operator<<(std::ostream& os, const KVpair& kv);
75 
76 } // namespace common
77 } // namespace dp3
78 
79 #endif
Implements a KV pair as a pair<string, string>.
Definition: KVpair.h:24
@ VT_TIME_T
Definition: KVpair.h:68
@ VT_FLOAT
Definition: KVpair.h:67
@ VT_INT
Definition: KVpair.h:65
@ VT_UNKNOWN
Definition: KVpair.h:62
@ VT_DOUBLE
Definition: KVpair.h:66
@ VT_BOOL
Definition: KVpair.h:64
@ VT_STRING
Definition: KVpair.h:63
KVpair(const std::string &aKey, float aValue, bool genTimestamp=false, bool timestampInKeyname=false)
bool operator==(const KVpair &that) const
Definition: KVpair.h:52
KVpair(const std::string &aKey, const std::string &aValue, bool genTimestamp=false, bool timestampInKeyname=false)
KVpair(const std::string &aKey, double aValue, bool genTimestamp=false, bool timestampInKeyname=false)
KVpair(const KVpair &that)
KVpair(const std::string &aKey, bool aValue, bool genTimestamp=false, bool timestampInKeyname=false)
KVpair(const std::string &aKey, const char *aValue, bool genTimestamp=false, bool timestampInKeyname=false)
int16_t valueType
Definition: KVpair.h:59
KVpair & operator=(const KVpair &that)
double timestamp
Definition: KVpair.h:58
KVpair(const std::string &aKey, int aValue, bool genTimestamp=false, bool timestampInKeyname=false)
KVpair(const std::string &aKey, time_t aValue, bool genTimestamp=false, bool timestampInKeyname=false)
std::ostream & operator<<(std::ostream &os, const KVpair &kv)
This file has generic helper routines for testing steps.
Definition: AntennaConfig.h:53