M1-nw-project/configFile.h

44 lines
993 B
C
Raw Permalink Normal View History

2016-11-24 15:26:42 +01:00
/***************************************************************************
* By Théophile Bastian, 2017
* M1 Network course project at ENS Cachan, Juliusz Chroboczek.
* License: WTFPL v2 <http://www.wtfpl.net/>
**************************************************************************/
#pragma once
#include <vector>
#include <string>
#include "data.h"
class ConfigFile {
public:
2016-11-27 13:26:27 +01:00
typedef std::string CfgData;
2016-11-24 15:26:42 +01:00
ConfigFile();
bool read(const char* path);
bool write(const char* path);
u64 getSelfId() const { return selfId; }
void setSelfId(u64 id) { selfId = id; }
/** Self id */
const std::vector<Neighbour>& getBootstrapNodes() const {
return bootstrapNodes;
};
/** Bootstrap nodes. No setter: wouldn't be useful. */
2016-11-27 13:26:27 +01:00
const std::vector<CfgData>& getData() const {
2016-11-26 19:17:56 +01:00
return data;
}
/** Data to publish. */
2016-11-24 15:26:42 +01:00
private:
2016-11-26 19:17:56 +01:00
u64 randId() const;
2016-11-24 15:26:42 +01:00
u64 selfId;
std::vector<Neighbour> bootstrapNodes;
2016-11-27 13:26:27 +01:00
std::vector<CfgData> data;
size_t curDataSum;
2016-11-24 15:26:42 +01:00
};