Versions Compared

Key

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

Component IDL

Code Block
languagecpp
collapsetrue
#ifndef _ASYNC_IDL_
#define _ASYNC_IDL_
 
#pragma prefix "acs"
 
#include <acscommon.idl>
#include <acscomponent.idl>
 
module examples
{
    interface MyCallback: ACS::OffShoot {
        void update(in string text);
    };

    interface Async : ACS::ACSComponent {
        oneway void delayResult(in ACS::uLong delay, in MyCallback cb);
    };
};
#endif

C++

Component Implementation

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_workshop::Async
{
  public:
    AsyncImpl(const ACE_CString& name, maci::ContainerServices* containerServices);
    virtual ~AsyncImpl();
    void delayResult(ACS::uLong delay, acs::examples::MyCallback_ptr cb);
};
#endif
Code Block
languagecpp
titleAsyncImpl.cpp
linenumberstrue
collapsetrue
#include <AsyncImpl.h>
#include <ACSErrTypeOK.h>
 
AsyncImpl::AsyncImpl(const ACE_CString& name, maci::ContainerServices* containerServices) : acscomponent::ACSComponentImpl(name, containerServices) {
}
 
AsyncImpl::~AsyncImpl() {
}
 
void AsyncImpl::delayResult(ACS::uLong delay, acs::examples::MyCallback_ptr cb) {
    cb->update("Working");
    sleep(delay);
    cb->update("Done");
}
 
/* --------------- [ MACI DLL support functions ] -----------------*/
#include <maciACSComponentDefines.h>
MACI_DLL_SUPPORT_FUNCTIONS(AsyncImpl)
/* ----------------------------------------------------------------*/


Standalone Client

Component Client