DRDE/AusRegCliever/include/mdHost.h

90 lines
2.7 KiB
C++

#include <boost/asio.hpp>
/*! \brief mdHost
* General abstraction of all MD clients
*
* For historical reasons all clients are considered to be
* devices. The central device of the system has zero
* device type.
*
*/
using namespace std;
using boost::asio::ip::udp;
template<class T>
class mdHost {
public:
bool isSingleton;
int clieverGroup, // masterDaemonConfig.thisMachineContext
handle,mdStdDevIdx;
md_device type;
mdState state;
std::string vendor;
udp::endpoint ip;
// Superset of the RFC speced
InstructionSet cmds;
// 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;}
T* registeR(md_device t);
void registrY(T* device,std::string operatorName);
void registerCmd(const char *cmdName,const mdIncoming &mdI);
};
class mdClientServer;
class mdClientServer : public mdHost<mdClientServer> {
public:
mdClientServer() : mdHost<mdClientServer>( MDDEV_CD ) {};
mdClientServer *validateClient(int handle, mdResponse &r);
};
class mdMachine;
class mdMachine : public mdHost<mdMachine> {
public:
mdMachine() : mdHost<mdMachine>( MACHINE ) {}
mdMachine *validateClient(int handle, const mdClientBirth &c, mdResponse &r);
void registerCmd(const char *cmdName,const mdIncoming &mdI);
};
class mdPeer;
class mdPeer : public mdHost<mdPeer> {
public:
mdPeer() : mdHost<mdPeer>( MDDEV_PEER )
{
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);
void registerCmd(const char *cmdName,const mdIncoming &mdI);
};
class masterDaemon;
class mdHostFabrik : public mdHost<masterDaemon>
{public:
mdHostFabrik() : mdHost<masterDaemon>( MDDEV_MD ) {}
void newFromHeartbeat(const mdClientBirth &itsAWhat);
std::string newFromAPI(md_device type,std::string signature);
};