Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

ManagerImpl.hh

Go to the documentation of this file.
00001 /*
00002  * ManagerImpl.hh
00003  *
00004  * Copyright (c) 2003, 2004 The University of Utah and the Flux Group.
00005  * All rights reserved.
00006  *
00007  * This file is licensed under the terms of the GNU Public License.  
00008  * See the file "license.terms" for restrictions on redistribution 
00009  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
00010  */
00011 
00012 /**
00013  * @file ManagerImpl.hh
00014  *
00015  * Header file for the default implementation of the Broker::Manager interface.
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  * A default implementation of the Broker::Manager interface.
00027  */
00028 class ManagerImpl : public virtual POA_Broker::Manager
00029 {
00030 
00031 public:
00032 
00033     /**
00034      * Construct a ManagerImpl.
00035      *
00036      * @param name The name of this manager.
00037      */
00038     ManagerImpl(const char *name);
00039 
00040     /**
00041      * Destruct a ManagerImpl.
00042      */
00043     virtual ~ManagerImpl();
00044 
00045     /** @copydoc Broker::Manager::CurrentPolicy */
00046     virtual Broker::Policy_ptr CurrentPolicy(void)
00047         throw (CORBA::SystemException);
00048     
00049     /** @copydoc Broker::Manager::CurrentPolicy */
00050     virtual void CurrentPolicy(Broker::Policy_ptr policy)
00051         throw (CORBA::SystemException);
00052 
00053     /** @copydoc Broker::Manager::AddTask */
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     /** @copydoc Broker::Manager::RemoveTask */
00062     virtual void RemoveTask(Broker::Task_ptr task)
00063         throw (CORBA::SystemException);
00064 
00065     /** @copydoc Broker::Manager::GetTaskList */
00066     virtual Broker::TaskList *GetTaskList(void)
00067         throw (CORBA::SystemException);
00068 
00069     /** @copydoc Broker::Manager::ChangeTaskCPU */
00070     virtual Broker::CPUReserve ChangeTaskCPU(Broker::RealTimeTask_ptr task,
00071                                              const Broker::CPUReserve &advice)
00072         throw (CORBA::SystemException, Broker::InvalidState);
00073 
00074     /**
00075      * Search of a task name in a Broker::TaskList.  Or, if the name is an IOR
00076      * return a reference to that object.
00077      *
00078      * @param orb A pointer to an active CORBA::ORB object.
00079      * @param tl The task list to search.
00080      * @param name The task name or task IOR.
00081      * @return An object reference that matches the given name or IOR.
00082      * @exception CORBA::BAD_PARAM if the task could not be found.
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      * List node used to track the tasks that are currently being managed.
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      * Repair the task list by removing any dead/unreachable objects.
00126      */
00127     void RepairTaskList(void);
00128 
00129     /**
00130      * Find a TaskNode in the task list.
00131      *
00132      * @param task The task to search for.
00133      * @return The corresponding TaskNode for the given task or NULL if none
00134      * was found.
00135      */
00136     struct TaskNode *FindTask(Broker::Task_ptr task);
00137     
00138     /**
00139      * The active policy object or nil.
00140      */
00141     Broker::Policy_var mi_CurrentPolicy;
00142 
00143     /**
00144      * The list of tasks currently being managed.  This list will be passed
00145      * to policies when they are Broker::Policy::Activate()'d.
00146      */
00147     struct lnMinList mi_Tasks;
00148 
00149 };
00150 
00151 #endif

Generated on Tue Jun 22 14:50:09 2004 for CPU Broker by doxygen 1.3.6