00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 #ifndef _manager_impl_hh
00019 #define _manager_impl_hh
00020 
00021 #include "BrokerS.h"
00022 
00023 #include <listNode.h>
00024 
00025 
00026 
00027 
00028 class ManagerImpl : public virtual POA_Broker::Manager
00029 {
00030 
00031 public:
00032 
00033 
00034 
00035 
00036 
00037 
00038     ManagerImpl(const char *name);
00039 
00040 
00041 
00042 
00043     virtual ~ManagerImpl();
00044 
00045 
00046     virtual Broker::Policy_ptr CurrentPolicy(void)
00047         throw (CORBA::SystemException);
00048     
00049 
00050     virtual void CurrentPolicy(Broker::Policy_ptr policy)
00051         throw (CORBA::SystemException);
00052 
00053 
00054     virtual void AddTask(Broker::Task_ptr task,
00055                          const Broker::ScheduleParameters &sp)
00056         throw (CORBA::SystemException,
00057                Broker::DuplicateScheduleParameter,
00058                Broker::InvalidScheduleParameter,
00059                Broker::MissingScheduleParameter);
00060 
00061 
00062     virtual void RemoveTask(Broker::Task_ptr task)
00063         throw (CORBA::SystemException);
00064 
00065 
00066     virtual Broker::TaskList *GetTaskList(void)
00067         throw (CORBA::SystemException);
00068 
00069 
00070     virtual Broker::CPUReserve ChangeTaskCPU(Broker::RealTimeTask_ptr task,
00071                                              const Broker::CPUReserve &advice)
00072         throw (CORBA::SystemException, Broker::InvalidState);
00073 
00074 
00075 
00076 
00077 
00078 
00079 
00080 
00081 
00082 
00083 
00084     static Broker::Task_ptr ResolveTask(CORBA::ORB_ptr orb,
00085                                         Broker::TaskList &tl,
00086                                         const char *name)
00087         throw (CORBA::SystemException);
00088     
00089 private:
00090 
00091 
00092 
00093 
00094     struct TaskNode
00095     {
00096         ~TaskNode(void)
00097         {
00098             if( !CORBA::is_nil(this->tn_Task.in()) )
00099             {
00100                 try
00101                 {
00102                     this->tn_Task->EndCPUScheduling();
00103                 }
00104                 catch(const CORBA::Exception &e)
00105                 {
00106                 }
00107                 try
00108                 {
00109                     this->tn_Task->SetManager(Broker::Manager::_nil());
00110                 }
00111                 catch(const CORBA::Exception &e)
00112                 {
00113                 }
00114                 this->tn_Task = Broker::Task::_nil();
00115             }
00116         };
00117         
00118         struct lnMinNode tn_Link;
00119         Broker::Task_var tn_Task;
00120         Broker::ScheduleParameters_var tn_ScheduleParameters;
00121         
00122     };
00123 
00124 
00125 
00126 
00127     void RepairTaskList(void);
00128 
00129 
00130 
00131 
00132 
00133 
00134 
00135 
00136     struct TaskNode *FindTask(Broker::Task_ptr task);
00137     
00138 
00139 
00140 
00141     Broker::Policy_var mi_CurrentPolicy;
00142 
00143 
00144 
00145 
00146 
00147     struct lnMinList mi_Tasks;
00148 
00149 };
00150 
00151 #endif