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 {
00069 unsigned int slot;
00070
00071 slot = this->sp_Tasks.length();
00072 this->sp_Tasks.length(slot + 1);
00073 this->sp_Tasks[slot] = task;
00074 };
00075
00076
00077
00078
00079
00080
00081 void RemoveTask(Broker::Task_ptr task)
00082 throw (CORBA::SystemException)
00083 {
00084 unsigned int lpc;
00085 int slot;
00086
00087 slot = this->TaskIndex(task);
00088 for( lpc = (unsigned int)slot;
00089 lpc < (this->sp_Tasks.length() - 1);
00090 lpc++ )
00091 {
00092 this->sp_Tasks[lpc] = this->sp_Tasks[lpc + 1];
00093 }
00094 this->sp_Tasks.length(this->sp_Tasks.length() - 1);
00095 };
00096
00097
00098
00099
00100 Broker::TaskList *GetTaskList(void)
00101 throw (CORBA::SystemException)
00102 {
00103 Broker::TaskList_var retval;
00104
00105 retval = new Broker::TaskList(this->sp_Tasks);
00106 return( retval._retn() );
00107 };
00108
00109
00110
00111
00112
00113
00114 void Activate(const Broker::TaskList &tasks)
00115 throw (CORBA::SystemException)
00116 {
00117 unsigned int lpc;
00118
00119 this->sp_Tasks.length(tasks.length());
00120 for( lpc = 0; lpc < tasks.length(); lpc++ )
00121 {
00122 this->sp_Tasks[lpc] = tasks[lpc];
00123 }
00124 };
00125
00126
00127
00128
00129 void Deactivate(void)
00130 throw (CORBA::SystemException)
00131 {
00132 this->sp_Tasks.length(0);
00133 };
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143 void ChangeTaskCPU(Broker::RealTimeTask_ptr task,
00144 CORBA::ULong ct,
00145 CORBA::ULong status,
00146 CORBA::ULong advice)
00147 throw (CORBA::SystemException, Broker::InvalidState)
00148 {
00149 task->SetComputeTime(advice);
00150 };
00151
00152
00153
00154
00155
00156
00157
00158
00159 int TaskIndex(Broker::Task_ptr task)
00160 {
00161 unsigned int lpc;
00162 int retval = -1;
00163
00164 for( lpc = 0;
00165 (lpc < this->sp_Tasks.length()) && (retval == -1);
00166 lpc++ )
00167 {
00168 if( this->sp_Tasks[lpc]->_is_equivalent(task) )
00169 {
00170 retval = lpc;
00171 }
00172 }
00173 return( retval );
00174 }
00175
00176
00177 CORBA::String_var sp_Name;
00178
00179 Broker::TaskList sp_Tasks;
00180
00181 };
00182
00183 #endif