MCS: Remove unused host specific mote info database
[remote/remote-mci.git] / mch / DeviceManager.h
blob685371fa59bea1b3ec4467bc6f1ec573adb74838
1 #ifndef REMOTE_MCH_DEVICEMANAGER_H
2 #define REMOTE_MCH_DEVICEMANAGER_H
4 #include <map>
5 #include <string>
6 #include <sys/types.h>
7 #include <sys/stat.h>
8 #include <unistd.h>
9 #include <stdio.h>
10 #include <fcntl.h>
11 #include <signal.h>
12 #include <stdlib.h>
13 #include <dirent.h>
15 #include "Mote.h"
17 namespace remote { namespace mch {
19 typedef std::map<std::string, Mote *> motemap_t;
21 /** MCH Mote device manager.
23 * The device manager maintains a database of known motes and their
24 * status. The database consists of three mote maps: one containing
25 * newly discovered motes, one with motes that are no longer available,
26 * and a map containing all currently valid and operational motes.
27 * The database can be updated using #refresh().
29 class DeviceManager
31 public:
32 motemap_t motes; /**< The current valid motes. */
33 motemap_t newMotes; /**< Motes that were just attached. */
34 motemap_t lostMotes; /**< Motes that were just detached. */
36 /** Refresh the mote device database.
38 * Update the registered devices to match the existing system using a
39 * "mark and sweep" approach. First all motes are marked invalid
40 * after which the mote device hierarchy is iterated to revalidate all
41 * available mote. Finally, motes that are still invalid are moved to
42 * the #lostMotes.
44 * @param devicePath The path to the mote devices.
46 void refresh(std::string devicePath);
48 private:
49 /** Traverse and update all available motes.
51 * Traverses all mote device directories under the given
52 * device path and updates the mote.
54 * @param devicePath The path to the mote devices.
56 void readMoteDevices(std::string devicePath);
58 /** Update mote information.
60 * If the mote already exists it is validated using
61 * #mch::Mote::validate else a new mote is created
62 * and placed in both #motes and #newMotes.
64 * @param mac The MAC address of the mote.
65 * @param directory The device directory of the mote.
67 void updateMote(std::string mac, std::string directory);
72 #endif