Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagecpp
titleAsyncImpl.h
linenumberstrue
collapsetrue
#ifndef _ASYNC_IMPL_H
#define _ASYNC_IMPL_H
 
#include <acscomponentImpl.h>
#include <AsyncS.h>
 
class AsyncImpl : public virtual acscomponent::ACSComponentImpl, public virtual POA_workshopexamples::Async
{
  public:
    AsyncImpl(const ACE_CString& name, maci::ContainerServices* containerServices);
    virtual ~AsyncImpl();
    void delayAsync(ACS::uLong delay, acs::examples::MyCallback_ptr cb);
};
#endif

...

Code Block
languagexml
titleComponents.xml
linenumberstrue
collapsetrue
<e Name="ASYNC_CPP"
   Code="AsyncImpl"
   Type="IDL:almaacs/workshopexamples/Async:1.0"
   Container="bilboContainer"
   ImplLang="cpp"
   KeepAliveTime="0"
/>
<e Name="ASYNC_CLIENT_CPP"
   Code="AsyncClientImpl"
   Type="IDL:almaacs/workshopexamples/AsyncClient:1.0"
   Container="bilboContainer"
   ImplLang="cpp"
   KeepAliveTime="0"
/>

...

Code Block
languagecpp
titleAsyncClient.cpp
linenumberstrue
collapsetrue
#include <maciSimpleClient.h>
#include <AsyncC.h>
#include <ACSErrTypeCommon.h>
#include <acsutilTimeStamp.h>
  
using namespace maci;
class MyCBImpl : public virtual POA_examples::MyCallback {
  public:
    MyCBImpl() {
        status=std::string("INIT");
    }
    virtual ~CBuLongImpl() {}
    void update(const char* value) {
        status = std::string(value);
    }
  public:
    std::string status;
};
  
int main(int argc, char *argv[]) {
    SimpleClient client;
    workshopexamples::Async_var comp;
  
    if (client.init(argc,argv) == 0) {
        return -1;
    } else {
        client.login();
    }
  
    try {
        comp = client.getComponent<workshopgetComponent<examples::Async>("ASYNC_CPP", 0, true);
    } catch(maciErrType::CannotGetComponentExImpl& _ex) {
        _ex.log();
        return -1;
    }
  
    CBuLongImpl cb;
    ACS::CBuLong_var cbObj = cb._this();
  
    ACS_SHORT_LOG((LM_INFO, "%s", cb.status));
    comp->delayAsync(8, cbObj.in());
  
    ACS_SHORT_LOG((LM_INFO, "%s", cb.status));
    sleep(5);
    ACS_SHORT_LOG((LM_INFO, "%s", cb.status));
    sleep(5);
  
    ACS_SHORT_LOG((LM_INFO, "%s", cb.status));
    ACS_SHORT_LOG((LM_INFO, "%ul", cb.value));
  
    try {
        client.releaseComponent("ASYNC_CPP");
    } catch(maciErrType::CannotReleaseComponentExImpl &_ex) {
        _ex.log();
        return -1;
    }
  
    client.logout();
  
    ACE_OS::sleep(3);
    return 0;
}

...

Code Block
languagecpp
titleAsyncImplAsyncClientImpl.h
linenumberstrue
collapsetrue
#ifndef _ASYNC_CLIENT_IMPL_H
#define _ASYNC_CLIENT_IMPL_H
 
#include <acscomponentImpl.h>
#include <AsyncS.h>
 
class AsyncClientImpl : public virtual acscomponent::ACSComponentImpl, public virtual POA_workshopexamples::AsyncAsyncClient
{
  public:
    AsyncImplAsyncClientImpl(const ACE_CString& name, maci::ContainerServices* containerServices);
    virtual ~AsyncImpl~AsyncClientImpl();
    void delayAsyncdelay(ACS::uLong delay, acs::examples::MyCallback_ptr cb);
};
#endif
Code Block
languagecpp
titleAsyncImplAsyncClientImpl.cpp
linenumberstrue
collapsetrue
#include <AsyncImpl<AsyncClientImpl.h>
#include <ACSErrTypeOK.h>
 
AsyncImplAsyncClientImpl::AsyncImplAsyncClientImpl(const ACE_CString& name, maci::ContainerServices* containerServices) : acscomponent::ACSComponentImpl(name, containerServices) {
}
 
AsyncImplAsyncClientImpl::~AsyncImpl~AsyncClientImpl() {
}
 
void AsyncImplAsyncClientImpl::delayAsyncdelay(ACS::uLong delay, acs::examples::MyCallback_ptr cb) {
    examples::Async_var comp  cb->update("WORKING"= getContainerServices().getComponent<examples::Async>("ASYNC_CPP", 0, true);
     sleep(delaycomp->delayAsync(8, cbObj.in());
    cb->update getContainerServices().releaseComponent("DONEASYNC_CPP");
}
 
/* --------------- [ MACI DLL support functions ] -----------------*/
#include <maciACSComponentDefines.h>
MACI_DLL_SUPPORT_FUNCTIONS(AsyncImpl)
/* ----------------------------------------------------------------*/