ObjectQ - Overview - simRequest.c
#include <Map.h>
#include "cpGenMgr.h"
#include "cpMsgUtil.h"
#include "cpResource.h"
#include "simRequest.h"

Requestor::Requestor()
{
}

Requestor::Requestor(const cpManagerResource &mRes, const String &service) :
_resource(mRes), _service(service)
{
}

Requestor::~Requestor()
{
}

cpStatus
Requestor::get(const String &className,
const List<cpAttribute> &attrList,
const cpInstanceId &id)
{
cpStatus ret;

// Create a manager to handle the request/response
cpGenericMgr* mgr = new cpGenericMgr(_resource, this, _service);

// Issue the get asynchronously (ie, don't wait for response)
ret = mgr->get("Simple.demoClass", attrList, id);

return ret;
}

void
Requestor::notifyComplete(cpManager *mgr)
{
cpGenericMgr* gMgr = (cpGenericMgr*)mgr;
const List<cpMessage*>* mlist;

// The manager called us - retrieve messages
mlist = gMgr->messages();
if (mlist) {
Const_listiter<cpMessage*> msgIter(*mlist);
cpMessage* respMsg;

// Display the instance name for each response
while (msgIter.next(respMsg))
cout << "Response: <" << respMsg->instanceId() << "> " << endl;
}

// We don't need the manager any more
delete gMgr;
}