00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "config.h"
00019
00020 #include <iostream>
00021 #include <assert_pp.h>
00022
00023 #include "ManagerImpl.hh"
00024 #include "StrictPolicyCallbackImpl.hh"
00025
00026 using namespace std;
00027
00028 StrictPolicyCallbackImpl::StrictPolicyCallbackImpl(
00029 BrokerPolicies::StrictPolicy_ptr sp) :
00030 spci_Policy(sp)
00031 {
00032 int argc = 0;
00033
00034 this->spci_ORB = CORBA::ORB_init(argc, (char **)NULL);
00035 }
00036
00037 StrictPolicyCallbackImpl::~StrictPolicyCallbackImpl(void)
00038 {
00039 }
00040
00041 void StrictPolicyCallbackImpl::sendMessage(const char *msg)
00042 throw (CORBA::SystemException)
00043 {
00044 require(msg != NULL);
00045
00046 cerr << msg << endl;
00047 }
00048
00049 void StrictPolicyCallbackImpl::SetPriorityOf(const char *task_name,
00050 CORBA::Short priority)
00051 throw (CORBA::SystemException)
00052 {
00053 Broker::Task_ptr task;
00054 Broker::TaskList *tl;
00055
00056 if( task_name == NULL )
00057 {
00058 throw CORBA::BAD_PARAM();
00059 }
00060 if( CORBA::is_nil(this->spci_Policy.in()) )
00061 {
00062 throw CORBA::BAD_INV_ORDER();
00063 }
00064
00065 tl = this->spci_Policy->GetTaskList();
00066 task = ManagerImpl::ResolveTask(this->spci_ORB, *tl, task_name);
00067 if( CORBA::is_nil(task) )
00068 {
00069 throw CORBA::BAD_PARAM();
00070 }
00071 this->spci_Policy->SetTaskPriority(task, priority);
00072 }
00073
00074 CORBA::Short StrictPolicyCallbackImpl::GetPriorityOf(const char *task_name)
00075 throw (CORBA::SystemException)
00076 {
00077 Broker::Task_ptr task;
00078 Broker::TaskList *tl;
00079 CORBA::Short retval;
00080
00081 if( task_name == NULL )
00082 {
00083 throw CORBA::BAD_PARAM();
00084 }
00085 if( CORBA::is_nil(this->spci_Policy.in()) )
00086 {
00087 throw CORBA::BAD_INV_ORDER();
00088 }
00089
00090 tl = this->spci_Policy->GetTaskList();
00091 task = ManagerImpl::ResolveTask(this->spci_ORB, *tl, task_name);
00092 if( CORBA::is_nil(task) )
00093 {
00094 throw CORBA::BAD_PARAM();
00095 }
00096 retval = this->spci_Policy->GetTaskPriority(task);
00097
00098 return( retval );
00099 }