sensorconfig_internal.h 3.49 KB
Newer Older
1
2
//================================================================================
// Name        : sensorconfig_internal.h
3
// Author      : Axel Auweter, Daniele Tafani
4
// Copyright   : Leibniz Supercomputing Centre
Michael Ott's avatar
Michael Ott committed
5
// Description : Internal Interface for configuring libdcdb public sensors.
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
//================================================================================

//================================================================================
// This file is part of DCDB (DataCenter DataBase)
// Copyright (C) 2011-2016 Leibniz Supercomputing Centre
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
//================================================================================
Axel Auweter's avatar
Axel Auweter committed
26
27

#include <list>
Axel Auweter's avatar
Axel Auweter committed
28
#include <string>
29
#include <unordered_map>
Axel Auweter's avatar
Axel Auweter committed
30
31

#include "cassandra.h"
Axel Auweter's avatar
Axel Auweter committed
32

33
34
35
#include "dcdb/connection.h"
#include "dcdb/timestamp.h"
#include "dcdb/sensorid.h"
Axel Auweter's avatar
Axel Auweter committed
36

37
#include "dcdb/sensorconfig.h"
Axel Auweter's avatar
Axel Auweter committed
38

39
40
41
42
#ifndef DCDB_SENSORCONFIG_INTERNAL_H
#define DCDB_SENSORCONFIG_INTERNAL_H

namespace DCDB {
Axel Auweter's avatar
Axel Auweter committed
43
44
45
46

class SensorConfigImpl
{
protected:
47
  Connection* connection;
48
  CassSession* session;
Axel Auweter's avatar
Axel Auweter committed
49

50
51
52
  typedef std::unordered_map<std::string, PublicSensor> SensorPropertyCache_t;
  static SensorPropertyCache_t sensorPropertyCache;

Axel Auweter's avatar
Axel Auweter committed
53
  bool validateSensorPattern(const char* sensorPattern);
54
  bool validateSensorPublicName(std::string publicName);
Axel Auweter's avatar
Axel Auweter committed
55
56

public:
Axel Auweter's avatar
Axel Auweter committed
57
  SCError publishSensor(std::string publicName, std::string sensorPattern);
58
  SCError publishVirtualSensor(std::string publicName, std::string vSensorExpression, std::string vSensorId, TimeStamp tZero, uint64_t frequency);
59
  SCError unPublishSensor(std::string publicName);
60
  SCError getPublicSensorNames(std::list<std::string>& publicSensors);
61
  SCError getPublicSensorsVerbose(std::list<PublicSensor>& publicSensors);
62

63
  SCError getPublicSensorByName(PublicSensor& sensor, const char* publicName);
64
65
  SCError getPublicSensorsByWildcard(std::list<PublicSensor>& sensors, const char* wildcard);
    
66
67
  SCError isVirtual(bool& isVirtual, std::string publicName);

Axel Auweter's avatar
Axel Auweter committed
68
69
  SCError getSensorPattern(std::string& pattern, std::string publicName);
  SCError getSensorListForPattern(std::list<SensorId>& sensorIds, std::string pattern);
70
  SCError getSensorListForPattern(std::list<SensorId>& sensorIds, std::string pattern, TimeStamp start, TimeStamp end);
Axel Auweter's avatar
Axel Auweter committed
71

72
73
  SCError setSensorScalingFactor(std::string publicName, double scalingFactor);
  SCError setSensorUnit(std::string publicName, std::string unit);
74
  SCError setSensorMask(std::string publicName, uint64_t mask);
75

76
77
78
79
  SCError setVirtualSensorExpression(std::string publicName, std::string expression);
  SCError setVirtualSensorTZero(std::string publicName, TimeStamp tZero);
  SCError setVirtualSensorFrequency(std::string publicName, uint64_t frequency);

80
  SensorConfigImpl(Connection* conn);
Axel Auweter's avatar
Axel Auweter committed
81
82
83
  virtual ~SensorConfigImpl();
};

84
85
86
} /* End of namespace DCDB */

#endif /* DCDB_SENSORCONFIG_INTERNAL_H */