SOLARIS_QT6_DAQ/influxdb.h

59 lines
1.5 KiB
C
Raw Normal View History

2023-01-25 14:59:48 -05:00
#ifndef INFLUXDB_H
#define INFLUXDB_H
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <curl/curl.h>
class InfluxDB{
private:
2023-02-13 18:40:02 -05:00
bool isURLValid;
2023-01-25 14:59:48 -05:00
CURL * curl;
CURLcode respond;
long respondCode;
std::string databaseIP;
std::string dataPoints;
std::vector<std::string> databaseList;
static size_t WriteCallBack(char *contents, size_t size, size_t nmemb, void *userp);
void Execute();
public:
/// url = https://fsunuc.physics.fsu.edu/InfluxDB/
InfluxDB(std::string url, bool verbose = false);
~InfluxDB();
void SetURL(std::string url);
2023-02-13 18:40:02 -05:00
bool TestingConnection();
bool IsURLValid() const {return isURLValid;}
2023-01-25 14:59:48 -05:00
/// Query
2023-02-14 17:39:49 -05:00
std::string CheckDatabases(); /// this save the list of database into databaseList
2023-01-25 14:59:48 -05:00
std::string Query(std::string databaseName, std::string query);
2023-02-14 17:39:49 -05:00
/// the CheckDatabases() function must be called before
2023-01-25 14:59:48 -05:00
std::vector<std::string> GetDatabaseList() {return databaseList;}
void CreateDatabase(std::string databaseName);
/// for single or batch write,
/// 1, addDataPoint first, you can add as many as you like
/// 2, writeData.
void AddDataPoint(std::string fullString);
2023-02-21 15:53:12 -05:00
unsigned int GetDataLength() const {return dataPoints.length();}
2023-01-25 14:59:48 -05:00
void ClearDataPointsBuffer();
void PrintDataPoints();
void WriteData(std::string databaseName);
2023-02-21 15:53:12 -05:00
bool IsWriteOK() const {return (respondCode == CURLE_OK) ? true: false;}
2023-01-25 14:59:48 -05:00
};
#endif