DRDE/AusRegCliever/include/mdHost.h

83 lines
2.1 KiB
C
Raw Normal View History

2014-01-03 08:27:31 +00:00
#include <boost/asio.hpp>
/*! \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>
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;
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.
~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;
class mdClientServer : public mdHost<mdClientServer> {
2014-01-03 08:27:31 +00:00
public:
mdClientServer() : mdHost<mdClientServer>( MDDEV_CD ) {};
2014-01-03 08:27:31 +00:00
mdClientServer *validateClient(int handle, mdResponse &r);
};
class mdMachine;
class mdMachine : public mdHost<mdMachine> {
2014-01-03 08:27:31 +00:00
public:
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);
};
class mdPeer;
class mdPeer : public mdHost<mdPeer> {
2014-01-03 08:27:31 +00:00
public:
mdPeer() : mdHost<mdPeer>( MDDEV_PEER )
{
cmds["RST"] = new mdCommand((md_mand)0,std::string("RST"));
}
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;
class mdHostFabrik : public mdHost<masterDaemon>
2014-01-03 08:27:31 +00:00
{public:
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);
};