summaryrefslogtreecommitdiff
path: root/CIAO/examples/BasicSP/EC/EC_exec.h
diff options
context:
space:
mode:
Diffstat (limited to 'CIAO/examples/BasicSP/EC/EC_exec.h')
-rw-r--r--CIAO/examples/BasicSP/EC/EC_exec.h167
1 files changed, 167 insertions, 0 deletions
diff --git a/CIAO/examples/BasicSP/EC/EC_exec.h b/CIAO/examples/BasicSP/EC/EC_exec.h
new file mode 100644
index 00000000000..69d54ac7d42
--- /dev/null
+++ b/CIAO/examples/BasicSP/EC/EC_exec.h
@@ -0,0 +1,167 @@
+// $Id$
+
+//============================================================
+/**
+ * @file EC_exec.h
+ *
+ * Header file for the actualy EC and ECHome component
+ * implementation.
+ *
+ * @author Balachandran Natarajan <bala@dre.vanderbilt.edu>
+ */
+//============================================================
+
+#ifndef EC_EXEC_H
+#define EC_EXEC_H
+
+#include "ECEIC.h"
+#include "tao/LocalObject.h"
+#include "ace/Thread_Manager.h"
+#include "ace/Task.h"
+
+namespace MyImpl
+{
+ // Forward decl.
+ class EC_exec_i;
+
+ /**
+ * @brief Active pulse generater
+ */
+ class timeout_Handler : public ACE_Task_Base
+ {
+ public:
+ // Default constructor
+ timeout_Handler (EC_exec_i *cb);
+ ~timeout_Handler ();
+
+ int open_h (void);
+
+ int close_h (void);
+
+ int start (CORBA::Long hertz);
+
+ int stop (void);
+
+ int active (void);
+
+ // Handle the timeout.
+ virtual int handle_timeout (const ACE_Time_Value &tv,
+ const void *arg);
+
+ // Called when <Time_Handler> is removed.
+ virtual int handle_close (ACE_HANDLE handle,
+ ACE_Reactor_Mask close_mask);
+
+ virtual int svc (void);
+
+ private:
+ /// Tracking whether we are actively generating pulse or not.
+ long active_;
+
+ /// Flag to indicate completion of this active object.
+ int done_;
+
+ /// The timer id we are waiting.
+ long tid_;
+
+ EC_exec_i *pulse_callback_;
+
+ ACE_Thread_Manager thr_mgr_;
+ };
+
+ /**
+ * @class EC_exec_i
+ *
+ * EC executor implementation class.
+ */
+ class EC_EXEC_Export EC_exec_i :
+ public virtual BasicSP::EC_Exec,
+ public virtual TAO_Local_RefCounted_Object
+ {
+ public:
+ /// Default constructor.
+ EC_exec_i ();
+
+ /// Initialize with a default frequency.
+ EC_exec_i (CORBA::Long hz);
+
+ /// Default destructor.
+ ~EC_exec_i ();
+
+ // Attribute operations.
+
+ virtual CORBA::Long hertz ();
+
+ virtual void hertz (CORBA::Long hertz);
+
+ // Operations from supported interface(s)
+
+ virtual void start ();
+
+ virtual void stop ();
+
+ virtual CORBA::Boolean active ();
+
+ // Operations from Components::SessionComponent
+
+ virtual void set_session_context (Components::SessionContext_ptr ctx);
+
+ virtual void ciao_preactivate ();
+
+ virtual void ccm_activate ();
+
+ virtual void ciao_postactivate ();
+
+
+ virtual void ccm_passivate ();
+
+ virtual void ccm_remove ();
+
+ /// Helper function to be called back by timeout_Handler
+ void pulse (void);
+
+ protected:
+ /// Frequency
+ CORBA::Long hertz_;
+
+ /// Copmponent specific context
+ BasicSP::CCM_EC_Context_var context_;
+
+ /// An active object that actually trigger the generation of
+ /// periodic events.
+ timeout_Handler pulser_;
+ };
+
+ /**
+ * @class ECHome_exec_i
+ *
+ * EC home executor implementation class.
+ */
+ class EC_EXEC_Export ECHome_exec_i :
+ public virtual BasicSP::CCM_ECHome,
+ public virtual TAO_Local_RefCounted_Object
+ {
+ public:
+ /// Default ctor.
+ ECHome_exec_i ();
+
+ /// Default dtor.
+ ~ECHome_exec_i ();
+
+ // Explicit home operations.
+
+ virtual ::Components::EnterpriseComponent_ptr
+ new_EC (CORBA::Long hertz);
+
+ // Implicit home operations.
+
+ virtual ::Components::EnterpriseComponent_ptr
+ create ();
+ };
+
+}
+
+extern "C" EC_EXEC_Export ::Components::HomeExecutorBase_ptr
+createECHome_Impl (void);
+
+#endif /* CIAO_ECGEN_EXEC_H */