M1-nw-project/configFile.h

43 lines
993 B
C++

/***************************************************************************
* 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:
typedef std::string CfgData;
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. */
const std::vector<CfgData>& getData() const {
return data;
}
/** Data to publish. */
private:
u64 randId() const;
u64 selfId;
std::vector<Neighbour> bootstrapNodes;
std::vector<CfgData> data;
size_t curDataSum;
};