1 |
ab11 |
1.1 |
#include <iostream> |
2 |
|
|
#include <string> |
3 |
|
|
#include <unistd.h> // linux header for the sleep function |
4 |
ab11 |
1.3 |
#ifndef SMALLNET_H /* Has the file been INCLUDE'd already? */ |
5 |
|
|
#define SMALLNET_H yes |
6 |
|
|
#include "SmallNet.h" |
7 |
|
|
#endif |
8 |
ab11 |
1.1 |
|
9 |
|
|
using std::string; |
10 |
|
|
|
11 |
|
|
class Config { |
12 |
|
|
|
13 |
|
|
public: |
14 |
|
|
// public methods |
15 |
ab11 |
1.3 |
Config( string serverName, int serverPort, int printDebug); |
16 |
ab11 |
1.1 |
int getUDPFilterPort(){ return UDPFilterPort; }; // inline function |
17 |
|
|
string getUDPFilterName(){ return UDPFilterName; }; // inline |
18 |
ab11 |
1.3 |
int getIntProperty( string propertyName ); |
19 |
|
|
string getStrProperty( string propertyName ); |
20 |
|
|
SmallNet * getSmallNet(){ return net; }; // returns a pointer to the smallnet class |
21 |
|
|
string getFilterName(){ return UDPFilterName; }; |
22 |
|
|
int getFilterPort(){ return TCPFilterPort; }; |
23 |
ab11 |
1.6 |
string getFQDN(){ return fQDN; }; // inline. Returns this host name. |
24 |
ab11 |
1.5 |
int chatHeartBeat(); |
25 |
ab11 |
1.1 |
|
26 |
|
|
// public variables |
27 |
|
|
|
28 |
|
|
private: |
29 |
|
|
// private methods |
30 |
ab11 |
1.6 |
int loadConfig(); // do the chat dialog |
31 |
|
|
int establishHeartbeat(); // tell smallnet to make a connection |
32 |
|
|
int chatHeartbeat(); // send the relevant commands to the heartbeat |
33 |
|
|
int destroyHeartbeat(); // tell smallnet to close a connection |
34 |
|
|
int establishConfig(); // tell smallnet to make a connection to the config manager |
35 |
|
|
int chatConfig(); // send the relevant commands to get the config |
36 |
|
|
int destroyConfig(); // tell smallnet to close the connection to the config manager |
37 |
ab11 |
1.1 |
|
38 |
|
|
|
39 |
|
|
// private (global) variables |
40 |
ab11 |
1.3 |
int MAX_CONNECTION_ATTEMPTS; // how many times should it try? |
41 |
ab11 |
1.1 |
int configConnectionRetryTime; // how long to wait before retrying a connection to the |
42 |
ab11 |
1.6 |
// config manager if a connection cannot be established |
43 |
ab11 |
1.1 |
string configName; // the name of the server which will return our config |
44 |
|
|
int configPort; // the port on the server which will return our config |
45 |
|
|
int UDPFilterPort; // the port number of our assigned filter |
46 |
ab11 |
1.6 |
string UDPFilterName; // the name of our assigned filter |
47 |
ab11 |
1.1 |
int TCPFilterPort; // the tcp port for heartbeats |
48 |
|
|
bool configChanged; // has the config changed since we last loaded it? |
49 |
ab11 |
1.6 |
string lastModified; // saves the last modifed long integer |
50 |
ab11 |
1.1 |
string fileList; // saves the last modifed file list |
51 |
ab11 |
1.4 |
string fQDN; |
52 |
ab11 |
1.1 |
int numProperties; // the number of properties which this host wants |
53 |
ab11 |
1.6 |
string propertyNames[20]; // an array of strings which corrisponds to... |
54 |
|
|
string propertyValues[20]; // these values |
55 |
ab11 |
1.3 |
SmallNet * net; // interface onto SmallNet |
56 |
ab11 |
1.6 |
int debug; // print debug info? |
57 |
ab11 |
1.1 |
|
58 |
|
|
|
59 |
|
|
|
60 |
|
|
}; // class Config |