Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / examples / RTCORBA / Activity / Activity.h
blob34582c21a3279e55f1fdc91af295decf82d426a6
1 /* -*- C++ -*- */
2 //=============================================================================
3 /**
4 * @file Activity.h
6 * An activity is a process that contains Tasks.
7 * Each Task is composed of certain units of Jobs.
8 * A Job can perform work that is local/remote.
9 * Each Job is identified with a name.
11 * @author Pradeep Gore <pradeep@cs.wustl.edu>
13 //=============================================================================
14 #ifndef ACTIVITY_H
15 #define ACTIVITY_H
17 #include "ace/Singleton.h"
18 #include "ace/Sched_Params.h"
19 #include "orbsvcs/CosNamingC.h"
20 #include "tao/RTPortableServer/RTPortableServer.h"
21 #include "tao/RTCORBA/Priority_Mapping_Manager.h"
22 #include "ace/Null_Mutex.h"
24 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
25 class ACE_Barrier;
26 ACE_END_VERSIONED_NAMESPACE_DECL
28 class Job_i;
29 class Periodic_Task;
30 class Builder;
32 /**
33 * @class Activity
35 * @brief Driver class that maintains the orb and collections of objects for
36 * generating activity in this process.
38 class Activity
40 friend class ACE_Singleton<Activity, ACE_Null_Mutex>;
42 private:
43 Activity ();
44 ~Activity ();
46 public:
47 /// initialize the ORB et. al.
48 int init (int& argc, ACE_TCHAR *argv []);
51 /// Activate the tasks, jobs, poas.
52 void run (int argc, ACE_TCHAR *argv[]);
54 /// Resolve the naming service.
55 int resolve_naming_service ();
57 /// = Accessors
58 CORBA::ORB_ptr orb ();
59 RTCORBA::Current_ptr current ();
60 void builder (Builder* builder);
62 /// Returns priority if server declared model else -1
63 CORBA::Short get_server_priority (CORBA::Object_ptr server);
64 /// = Callbacks
65 /// Task ended notification
66 void task_ended (Periodic_Task* ended_task);
68 /// Job shutdown notification
69 void job_ended (Job_i* ended_job);
71 protected:
72 /// = Activation methods.
73 /// Activate the POA's
74 void activate_poa_list ();
76 /// Activate the task list.
77 void activate_schedule ();
79 /// Activate the Job's
80 void activate_job_list ();
82 /// Check if we should process exit
83 void check_ifexit ();
85 /// Create a file whose name is specified in the -Started_Flag <file_name> argument at startup.
86 /// This file flags that the Activity has finished its bootstrapping step.
87 void create_started_flag_file (int argc, ACE_TCHAR *argv[]);
89 /// = Data members
91 /// The Builder object.
92 Builder* builder_;
94 /// ACE_Barrier to synch. tasks.
95 ACE_Barrier* barrier_;
97 /// Mutex to serialize access to our internal state.
98 ACE_Lock* state_lock_;
100 /// The ORB that we use.
101 CORBA::ORB_var orb_;
103 /// RT ORB
104 RTCORBA::RTORB_var rt_orb_;
106 /// Current
107 RTCORBA::Current_var current_;
109 /// Reference to the root poa.
110 PortableServer::POA_var root_poa_;
112 /// A naming context.
113 CosNaming::NamingContextExt_ptr naming_;
115 /// The Priority Mapping helper.
116 RTCORBA::PriorityMapping *priority_mapping_;
118 /// Count the number of periodic tasks active.
119 int active_task_count_;
121 /// Count the number of Jobs active
122 int active_job_count_;
125 typedef ACE_Singleton<Activity, ACE_Null_Mutex> ACTIVITY;
127 #endif /* ACTIVITY_H */