Initial commit

This commit is contained in:
2020-05-01 11:03:00 +02:00
commit 3a12256d49
16 changed files with 278 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
#ifndef DATAID_H
#define DATAID_H
#include <string>
namespace DataStorage {
class DataId
{
public:
DataId(const std::string& dataName);
int Id() const;
std::string Table() const;
private:
int GetId(const std::string& dataName) const;
private:
std::string m_table;
};
} // namespace DataStorage
#endif // DATAID_H
+37
View File
@@ -0,0 +1,37 @@
#ifndef DATASTORAGECLIENT_H
#define DATASTORAGECLIENT_H
#include "Timespan.h"
#include <memory>
#include <string>
namespace MySQL {
class MySQLClient;
} // namespace MySQL
namespace DataStorage {
class DataStorageClientImpl;
class DataStorageClient
{
public:
DataStorageClient(const std::shared_ptr<MySQL::MySQLClient>& pMySQLClient, const std::string& table);
~DataStorageClient();
public:
void LogValue(int deviceId, const std::string& dataName, int timestamp, int value);
void LogValue(int deviceId, const std::string& dataName, int timestamp, double value);
void LogValue(int deviceId, const std::string& dataName, int timestamp, const std::string& value);
private:
std::shared_ptr<MySQL::MySQLClient> m_pMySQLClient;
std::string m_table;
};
} // namespace DataStorage
#endif // DATASTORAGECLIENT_H
+30
View File
@@ -0,0 +1,30 @@
#ifndef TIMESPAN_H
#define TIMESPAN_H
#include <string>
namespace DataStorage {
struct Timespan
{
enum type
{
Day = 24 * 60 * 60,
Week = 7 * 24 * 60 * 60,
Month = 31 * 24 * 60 * 60,
Year = 365 * 24 * 60 * 60,
Unknown
};
};
namespace Conversions {
Timespan::type Timespan(const std::string& timespan);
std::string Timespan(Timespan::type timespan);
} // namespace Conversions
} // namespace DataStorage
#endif // TIMESPAN_H