DRDE/AusRegCliever/include/mdHost.h

90 lines
2.7 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-18 20:35:18 +00:00
std::string vendor;
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);
2014-01-18 20:35:18 +00:00
void registrY(T* device,std::string operatorName);
2014-01-03 08:27:31 +00:00
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 )
{
2014-01-18 20:35:18 +00:00
cmds["check"] = new mdCommand((md_mand)0,std::string("CHK"));
cmds["info"] = new mdCommand((md_mand)0,std::string("INF"));
cmds["poll"] = new mdCommand((md_mand)0,std::string("POL"));
cmds["transfer query"] = new mdCommand((md_mand)0,std::string("TQY"));
cmds["create"] = new mdCommand((md_mand)0,std::string("REG"));
cmds["renew"] = new mdCommand((md_mand)0,std::string("REN"));
cmds["poll"] = new mdCommand((md_mand)0,std::string("POL"));
cmds["transfer query"] = new mdCommand((md_mand)0,std::string("TQY"));
}
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);
};