summaryrefslogtreecommitdiff
path: root/node/NodeConfig.hpp
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2014-09-12 16:57:37 -0700
committerAdam Ierymenko <adam.ierymenko@gmail.com>2014-09-12 16:57:37 -0700
commit1d37204a37b9ce58fa1ef67d4a209573e559c391 (patch)
treeaec9a0a4c7cf4a3204d7407e76696d15ed32220e /node/NodeConfig.hpp
parent6b4346d1ac9c7bb25b810be4db62fc6e3d38a189 (diff)
downloadinfinitytier-1d37204a37b9ce58fa1ef67d4a209573e559c391.tar.gz
infinitytier-1d37204a37b9ce58fa1ef67d4a209573e559c391.zip
Refactoring in progress... pardon our dust...
Diffstat (limited to 'node/NodeConfig.hpp')
-rw-r--r--node/NodeConfig.hpp38
1 files changed, 36 insertions, 2 deletions
diff --git a/node/NodeConfig.hpp b/node/NodeConfig.hpp
index b9bc8f5f..d374eee6 100644
--- a/node/NodeConfig.hpp
+++ b/node/NodeConfig.hpp
@@ -36,8 +36,6 @@
#include <vector>
#include <stdexcept>
-#include "IpcListener.hpp"
-#include "IpcConnection.hpp"
#include "SharedPtr.hpp"
#include "Network.hpp"
#include "Utils.hpp"
@@ -105,6 +103,38 @@ public:
}
/**
+ * Join a network or return existing network if already joined
+ *
+ * @param nwid Network ID to join
+ * @return New network instance
+ */
+ inline SharedPtr<Network> join(uint64_t nwid)
+ {
+ Mutex::Lock _l(_networks_m);
+ SharedPtr<Network> &nw = _networks[nwid];
+ if (nw)
+ return nw;
+ else return (nw = Network::newInstance(_r,this,nwid));
+ }
+
+ /**
+ * Leave a network
+ *
+ * @param nwid Network ID
+ * @return True if network was left, false if we were not a member of this network
+ */
+ inline bool leave(uint64_t nwid)
+ {
+ Mutex::Lock _l(_networks_m);
+ std::map< uint64_t,SharedPtr<Network> >::iterator n(_networks.find(nwid));
+ if (n != _networks.end()) {
+ n->second->destroy();
+ _networks.erase(n);
+ return true;
+ } else return false;
+ }
+
+ /**
* Perform cleanup and possibly persist saved state
*/
void clean();
@@ -135,18 +165,22 @@ public:
}
private:
+ /*
static void _CBcommandHandler(void *arg,IpcConnection *ipcc,IpcConnection::EventType event,const char *commandLine);
void _doCommand(IpcConnection *ipcc,const char *commandLine);
+ */
void _readLocalConfig();
void _writeLocalConfig();
const RuntimeEnvironment *_r;
+ /*
IpcListener _ipcListener;
std::string _authToken;
std::map< IpcConnection *,bool > _connections;
Mutex _connections_m;
+ */
Dictionary _localConfig; // persisted as local.conf
Mutex _localConfig_m;