ReasonerMessageDataType ReasonerCommunication::parseReceivedData(const char * buffer, uint64_t buffer_size){
	ReasonerMessageData data;
	uint64_t pos = 0;

	j_serialization::deserialize(data, buffer, pos, buffer_size);

	// cout << "parseReceivedData: " << (int) data.containedData << endl;


	if (data.containedData == ReasonerMessageDataType::NONE){
		return ReasonerMessageDataType::NONE;
	}

	ReasonerMessageDataType expectedResponse;

	ReasonerMessageReceived rmr( data.reasonerID );

	switch( data.containedData ){
	case (ReasonerMessageDataType::PROCESS) : {
		ProcessHealth health;
		j_serialization::deserialize( health, buffer, pos, buffer_size );

		// invoke the callback
		cb.receivedReasonerProcessHealth(rmr, health);

		expectedResponse = ReasonerMessageDataType::NODE;
		break;
	}
	case (ReasonerMessageDataType::NODE) : {
		NodeHealth health;
		j_serialization::deserialize( health, buffer, pos, buffer_size );
		// invoke the callback
		cb.receivedReasonerNodeHealth(rmr, health);

		expectedResponse = ReasonerMessageDataType::SYSTEM;
		break;
	}
	case (ReasonerMessageDataType::SYSTEM) : {
		SystemHealth health;
		j_serialization::deserialize( health, buffer, pos, buffer_size );
		// invoke the callback
		cb.receivedReasonerSystemHealth(rmr, health);

		expectedResponse = ReasonerMessageDataType::NONE;
		break;
	}
	case (ReasonerMessageDataType::NONE) :{
	}
	}

	return expectedResponse;
}
Example #2
0
int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);
    Q_UNUSED(a)
    if (argc >= 3 && !qstrcmp(argv[1], "ls"))
        return ls(argc -2, argv + 2);

    if (argc == 4 && !qstrcmp(argv[1], "mv"))
        return mv(argv[2], argv[3]);

    if (argc == 4 && !qstrcmp(argv[1], "cp"))
        return cp(argv[2], argv[3]);

    if (argc == 3 && !qstrcmp(argv[1], "rm"))
        return rm(argv[2]);

    if (argc == 3 && !qstrcmp(argv[1], "rmr"))
        return rmr(argv[2]);

    std::cerr << usage1 << argv[0] << usage2;
    return 0;
}