2014-01-03 08:27:31 +00:00
|
|
|
|
|
|
|
#include <boost/asio.hpp>
|
|
|
|
|
2014-01-05 22:58:00 +00:00
|
|
|
/*! \brief mdHost
|
2014-01-03 08:27:31 +00:00
|
|
|
* General abstraction of all MD clients
|
|
|
|
*
|
|
|
|
* For historical reasons all clients are considered to be
|
2014-01-07 17:59:27 +00:00
|
|
|
* devices. The central device of the system has zero
|
2014-01-03 08:27:31 +00:00
|
|
|
* device type.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using boost::asio::ip::udp;
|
|
|
|
|
|
|
|
template<class T>
|
2014-01-05 22:58:00 +00:00
|
|
|
class mdHost {
|
2014-01-03 08:27:31 +00:00
|
|
|
public:
|
|
|
|
|
|
|
|
bool isSingleton;
|
2014-01-07 17:59:27 +00:00
|
|
|
int clieverGroup, // masterDaemonConfig.thisMachineContext
|
2014-01-03 08:27:31 +00:00
|
|
|
handle,mdStdDevIdx;
|
|
|
|
md_device type;
|
2014-01-06 19:19:17 +00:00
|
|
|
mdState state;
|
2014-01-03 08:27:31 +00:00
|
|
|
|
|
|
|
udp::endpoint ip;
|
|
|
|
|
2014-01-07 17:59:27 +00:00
|
|
|
// Superset of the RFC speced
|
|
|
|
InstructionSet cmds;
|
2014-01-03 08:27:31 +00:00
|
|
|
|
|
|
|
// Some parameters initially here are now all uniformly ODEs
|
|
|
|
// defined in the COOL scripts.
|
|
|
|
|
2014-01-05 22:58:00 +00:00
|
|
|
~mdHost() {}
|
|
|
|
mdHost(md_device t) : type(t) {clieverGroup = handle = mdStdDevIdx = -1;}
|
2014-01-03 08:27:31 +00:00
|
|
|
|
|
|
|
T* registeR(md_device t);
|
|
|
|
|
|
|
|
void registerCmd(const char *cmdName,const mdIncoming &mdI);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
class mdClientServer;
|
2014-01-05 22:58:00 +00:00
|
|
|
class mdClientServer : public mdHost<mdClientServer> {
|
2014-01-03 08:27:31 +00:00
|
|
|
public:
|
|
|
|
|
2014-01-05 22:58:00 +00:00
|
|
|
mdClientServer() : mdHost<mdClientServer>( MDDEV_CD ) {};
|
2014-01-03 08:27:31 +00:00
|
|
|
mdClientServer *validateClient(int handle, mdResponse &r);
|
|
|
|
};
|
|
|
|
|
|
|
|
class mdMachine;
|
2014-01-05 22:58:00 +00:00
|
|
|
class mdMachine : public mdHost<mdMachine> {
|
2014-01-03 08:27:31 +00:00
|
|
|
public:
|
|
|
|
|
2014-01-05 22:58:00 +00:00
|
|
|
mdMachine() : mdHost<mdMachine>( MACHINE ) {}
|
|
|
|
|
2014-01-03 08:27:31 +00:00
|
|
|
mdMachine *validateClient(int handle, const mdClientBirth &c, mdResponse &r);
|
|
|
|
void registerCmd(const char *cmdName,const mdIncoming &mdI);
|
|
|
|
};
|
|
|
|
|
2014-01-05 22:58:00 +00:00
|
|
|
|
2014-01-06 19:19:17 +00:00
|
|
|
class mdPeer;
|
|
|
|
class mdPeer : public mdHost<mdPeer> {
|
2014-01-03 08:27:31 +00:00
|
|
|
public:
|
|
|
|
|
2014-01-06 19:19:17 +00:00
|
|
|
mdPeer() : mdHost<mdPeer>( MDDEV_PEER )
|
2014-01-05 22:58:00 +00:00
|
|
|
{
|
|
|
|
cmds["RST"] = new mdCommand((md_mand)0,std::string("RST"));
|
|
|
|
}
|
2014-01-06 19:19:17 +00:00
|
|
|
mdPeer *validateClient(int handle, const mdClientBirth &c, mdResponse &r);
|
2014-01-03 08:27:31 +00:00
|
|
|
void registerCmd(const char *cmdName,const mdIncoming &mdI);
|
|
|
|
};
|
|
|
|
|
|
|
|
class masterDaemon;
|
2014-01-05 22:58:00 +00:00
|
|
|
class mdHostFabrik : public mdHost<masterDaemon>
|
2014-01-03 08:27:31 +00:00
|
|
|
{public:
|
|
|
|
|
2014-01-05 22:58:00 +00:00
|
|
|
mdHostFabrik() : mdHost<masterDaemon>( MDDEV_MD ) {}
|
2014-01-03 08:27:31 +00:00
|
|
|
void newFromHeartbeat(const mdClientBirth &itsAWhat);
|
|
|
|
std::string newFromAPI(md_device type,std::string signature);
|
|
|
|
|
|
|
|
};
|