00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef _stub_policy_hh
00019 #define _stub_policy_hh
00020
00021 #include "BrokerS.h"
00022
00023
00024
00025
00026 class StubPolicy : public POA_Broker::Policy
00027 {
00028
00029 public:
00030
00031
00032
00033
00034
00035
00036 StubPolicy(const char *name)
00037 {
00038 this->sp_Name = name;
00039 };
00040
00041
00042
00043
00044 virtual ~StubPolicy()
00045 {
00046 };
00047
00048
00049
00050
00051 char *Name(void)
00052 throw (CORBA::SystemException)
00053 {
00054 CORBA::String_var retval;
00055
00056 retval = this->sp_Name;
00057 return( retval._retn() );
00058 }
00059
00060
00061
00062
00063
00064
00065
00066 void AddTask(Broker::Task_ptr task, const Broker::ScheduleParameters &sp)
00067 throw (CORBA::SystemException,
00068 Broker::DuplicateScheduleParameter,
00069 Broker::InvalidScheduleParameter,
00070 Broker::MissingScheduleParameter)
00071 {
00072 unsigned int slot;
00073
00074 slot = this->sp_Tasks.length();
00075 this->sp_Tasks.length(slot + 1);
00076 this->sp_Tasks[slot] = Broker::Task::_duplicate(task);
00077 };
00078
00079
00080
00081
00082
00083
00084 void RemoveTask(Broker::Task_ptr task)
00085 throw (CORBA::SystemException)
00086 {
00087 unsigned int lpc;
00088 int slot;
00089
00090 slot = this->TaskIndex(task);
00091 for( lpc = (unsigned int)slot;
00092 lpc < (this->sp_Tasks.length() - 1);
00093 lpc++ )
00094 {
00095 this->sp_Tasks[lpc] = this->sp_Tasks[lpc + 1];
00096 }
00097 this->sp_Tasks.length(this->sp_Tasks.length() - 1);
00098 };
00099
00100
00101
00102
00103 Broker::TaskList *GetTaskList(void)
00104 throw (CORBA::SystemException)
00105 {
00106 Broker::TaskList_var retval;
00107
00108 retval = new Broker::TaskList(this->sp_Tasks);
00109 return( retval._retn() );
00110 };
00111
00112
00113
00114
00115
00116
00117 void Activate(const Broker::TaskList &tasks)
00118 throw (CORBA::SystemException)
00119 {
00120 unsigned int lpc;
00121
00122 this->sp_Tasks.length(tasks.length());
00123 for( lpc = 0; lpc < tasks.length(); lpc++ )
00124 {
00125 this->sp_Tasks[lpc] = tasks[lpc];
00126 }
00127 };
00128
00129
00130
00131
00132 void Deactivate(void)
00133 throw (CORBA::SystemException)
00134 {
00135 this->sp_Tasks.length(0);
00136 };
00137
00138
00139
00140
00141
00142
00143
00144 Broker::CPUReserve ChangeTaskCPU(Broker::RealTimeTask_ptr task,
00145 const Broker::CPUReserve &advice)
00146 throw (CORBA::SystemException, Broker::InvalidState)
00147 {
00148 Broker::CPUReserve retval;
00149
00150 retval = advice;
00151 retval.Compute = 0;
00152 return retval;
00153 };
00154
00155
00156 virtual CORBA::Float GetMaxCPUAllocation(void)
00157 throw (CORBA::SystemException)
00158 {
00159 return this->sp_MaxCPUAllocation;
00160 };
00161
00162
00163 virtual void SetMaxCPUAllocation(CORBA::Float amount)
00164 throw (CORBA::SystemException)
00165 {
00166 this->sp_MaxCPUAllocation = amount;
00167 };
00168
00169
00170
00171
00172
00173
00174
00175
00176 int TaskIndex(Broker::Task_ptr task)
00177 {
00178 unsigned int lpc;
00179 int retval = -1;
00180
00181 for( lpc = 0;
00182 (lpc < this->sp_Tasks.length()) && (retval == -1);
00183 lpc++ )
00184 {
00185 if( this->sp_Tasks[lpc]->_is_equivalent(task) )
00186 {
00187 retval = lpc;
00188 }
00189 }
00190 return( retval );
00191 }
00192
00193
00194 CORBA::String_var sp_Name;
00195
00196 Broker::TaskList sp_Tasks;
00197
00198 CORBA::Float sp_MaxCPUAllocation;
00199
00200 };
00201
00202 #endif