producer_impl.cc

来自「MICO2.3.13 corba 环境平台」· CC 代码 · 共 81 行

CC
81
字号
#include "producer.h"#include "message_impl.h"class MyProducer_impl : virtual public MyProducer{private:  CCM_Producer_Context_var _ctx;  Message_var _mymsg;  bool active;public:  MyProducer_impl ()    {      _mymsg = new Message_impl;      _mymsg->text ((const char*) "Hello World!");      active = false;    }  void myMessage (Message * newmsg)    {      CORBA::add_ref (newmsg);      _mymsg = newmsg;    }  Message * myMessage ()    {      CORBA::add_ref (_mymsg);      return _mymsg;    }  void run (CORBA::ULong count)    {      if (active) {	for (CORBA::ULong i=0; i<count; i++) {	  _ctx->push_msg (_mymsg);	}      }    }  void set_session_context (Components::SessionContext_ptr ctx)    {      _ctx = CCM_Producer_Context::_narrow (ctx);    }  void ccm_activate ()    {      if (!active) {	active = true;	run (1);      }    }  void ccm_passivate ()    {      active = false;    }  void ccm_remove ()    {    }};class MyProducerHome_impl : virtual public CCM_ProducerHome {public:  Components::EnterpriseComponent_ptr create ()    {      return new MyProducer_impl;    }};extern "C" {  Components::HomeExecutorBase_ptr  create_ProducerHome (CORBA::ORB_ptr orb)  {    CORBA::ValueFactoryBase_var f = new MessageFactory;    orb->register_value_factory ("IDL:Message:1.0", f);    return new MyProducerHome_impl;  }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?