00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "OperationDef.h"
00024
00025 #include "idltype.h"
00026 #include "Container.h"
00027 #include "ExceptionDef.h"
00028 #include "PersistNode.h"
00029 #include "string_to.h"
00030
00031 namespace Omniifr {
00032
00033 TypeCode_ptr
00034 OperationDef_impl::result()
00035 {
00036 return TypeCode::_duplicate(_result.in());
00037 }
00038
00039 IDLType_ptr
00040 OperationDef_impl::result_def()
00041 {
00042 return IDLType::_duplicate(_result_def.in());
00043 }
00044
00045 void
00046 OperationDef_impl::result_def(IDLType_ptr v)
00047 {
00048 checkReadonly();
00049 checkOneway(_mode,_params.in(),v);
00050 _result_def.assign(IDLType::_duplicate(v));
00051 _result=v->type();
00052 }
00053
00054 ParDescriptionSeq* OperationDef_impl::params()
00055 {
00056 return _params.copy();
00057 }
00058
00059 void OperationDef_impl::params(const ParDescriptionSeq& v)
00060 {
00061 checkReadonly();
00062 checkOneway(_mode,v,_result_def.in());
00063 _params.assign(v);
00064 }
00065
00066 OperationMode OperationDef_impl::mode()
00067 {
00068 return _mode;
00069 }
00070
00071 void OperationDef_impl::mode(OperationMode v)
00072 {
00073 checkReadonly();
00074 if(v!=OP_NORMAL && v!=OP_ONEWAY)
00075 throw CORBA::BAD_PARAM(
00076 IFELSE_OMNIORB4(omni::BAD_PARAM_EnumValueOutOfRange,25),
00077 CORBA::COMPLETED_NO
00078 );
00079 checkOneway(v,_params.in(),_result_def.in());
00080 _mode=v;
00081 }
00082
00083 ContextIdSeq* OperationDef_impl::contexts()
00084 {
00085 return new ContextIdSeq(_contexts);
00086 }
00087
00088 void OperationDef_impl::contexts(const ContextIdSeq& v)
00089 {
00090 checkReadonly();
00091 _contexts=v;
00092 }
00093
00094 ExceptionDefSeq* OperationDef_impl::exceptions()
00095 {
00096 return _exceptions.copy();
00097 }
00098
00099 void OperationDef_impl::exceptions(const ExceptionDefSeq& v)
00100 {
00101 checkReadonly();
00102
00103
00104 ExcDescriptionSeq eds;
00105 eds.length(v.length());
00106 for(CORBA::ULong i=0; i<v.length(); i++)
00107 {
00108 CORBA::Contained::Description_var description =v[i]->describe();
00109 const ExceptionDescription* exceptionDescription;
00110 Boolean ok( description->value >>= exceptionDescription );
00111 if(!ok)
00112 throw CORBA::BAD_PARAM(
00113 IFELSE_OMNIORB4(omni::BAD_PARAM_EnumValueOutOfRange,25),
00114 CORBA::COMPLETED_NO
00115 );
00116 eds[i]=*exceptionDescription;
00117
00118 }
00119
00120
00121
00122 _exceptions.assign(v);
00123 _excDescriptionSeq=eds;
00124 }
00125
00126 CORBA::Contained::Description* OperationDef_impl::describe()
00127 {
00128 OperationDescription_var desc =new OperationDescription();
00129 desc->name = name();
00130 desc->id = id();
00131 desc->version = version();
00132 desc->result = result();
00133 desc->mode = _mode;
00134 desc->contexts = _contexts;
00135 desc->parameters = _params.in();
00136 desc->exceptions = _excDescriptionSeq;
00137 desc->defined_in = definedInId();
00138
00139 CORBA::Contained::Description_var description =
00140 new CORBA::Contained::Description();
00141 description->kind = def_kind();
00142 description->value <<= desc._retn();
00143
00144 return description._retn();
00145 }
00146
00147 void OperationDef_impl::uncheckedDestroy()
00148 {
00149 _result_def.clear();
00150 _params.clear();
00151 _exceptions.clear();
00152 Contained_impl::uncheckedDestroy();
00153 }
00154
00155 void OperationDef_impl::reincarnate(const PersistNode& node)
00156 {
00157 _result_def.assign(
00158 string_to_<CORBA::IDLType>(node.attrString("result_def").c_str())
00159 );
00160
00161
00162 cdrMemoryStream memstr =node.attrCdrStream("state");
00163 _result=TypeCode::unmarshalTypeCode(memstr);
00164 ParDescriptionSeq p;
00165 p<<=memstr;
00166 _params.uncheckedAssign(p);
00167 _mode<<=memstr;
00168 _contexts<<=memstr;
00169 ExceptionDefSeq e;
00170 e<<=memstr;
00171 _exceptions.assign(e);
00172 _excDescriptionSeq<<=memstr;
00173 }
00174
00175 void OperationDef_impl::output(ostream &os)
00176 {
00177 outputSelf(os,"OperationDef");
00178 PersistNode::outputIOR(os,_result_def.in(),"\n result_def=");
00179 cdrMemoryStream memstr(CORBA::ULong(0),CORBA::Boolean(1));
00180 TypeCode::marshalTypeCode(_result.in(),memstr);
00181 _params.in()>>=memstr;
00182 _mode>>=memstr;
00183 _contexts>>=memstr;
00184 _exceptions.in()>>=memstr;
00185 _excDescriptionSeq>>=memstr;
00186 PersistNode::outputCdrMemoryStream(os,memstr,"\n state=");
00187 os<<" ;;\n";
00188 }
00189
00190 void OperationDef_impl::checkOneway(
00191 const OperationMode mode,
00192 const ParDescriptionSeq& params,
00193 IDLType_ptr result_def
00194 ) const
00195 {
00196
00197
00198
00199 if(mode==OP_ONEWAY && !CORBA::is_nil(result_def))
00200 {
00201
00202 TypeCode_var resultTc =result_def->type();
00203 if(resultTc->kind()!=tk_void)
00204 throw CORBA::BAD_PARAM(31,CORBA::COMPLETED_NO);
00205
00206
00207 for(ULong i=0; i<params.length(); ++i)
00208 {
00209 if(params[i].mode!=PARAM_IN)
00210 throw CORBA::BAD_PARAM(31,CORBA::COMPLETED_NO);
00211 }
00212 }
00213 }
00214
00215 }