00001 #ifndef SCTAPI_MARSHALLING_H
00002 #define SCTAPI_MARSHALLING_H
00003
00004 #include <vector>
00005 #include "Sct/SequenceUtils.h"
00006
00007 Sct_SctApi::BOCChannelList * copyBOCChannelConfigVectorToCorba(const std::vector<SctConfiguration::BOCChannelConfig> &configList) {
00008
00009 Sct_SctApi::BOCChannelList * result = ::Sct::SequenceUtils::newSafeSequence<Sct_SctApi::BOCChannelList>(configList.size());
00010
00011 for(unsigned long i=0; i<configList.size(); i++) {
00012 const SctConfiguration::BOCChannelConfig &config = configList[i];
00013
00014 sctConf::BOCChannelConfig res;
00015
00016 res.current = config.current;
00017 res.delay = config.delay;
00018 res.markSpace = config.markSpace;
00019 res.threshold0 = config.threshold0;
00020 res.delay0 = config.delay0;
00021 res.threshold1 = config.threshold1;
00022 res.delay1 = config.delay1;
00023
00024 (*result)[i]=res;
00025 }
00026
00027 return result;
00028 }
00029
00030
00031 Sct_SctApi::AutoResultList * copyAutoResultListToCorba(const std::list< ::SctApi::AutoConf::AutoResult> &autoList) {
00032 Sct_SctApi::AutoResultList * result = ::Sct::SequenceUtils::newSafeSequence<Sct_SctApi::AutoResultList>(autoList.size());
00033
00034
00035
00036 unsigned int i=0;
00037
00038 for(std::list< ::SctApi::AutoConf::AutoResult>::const_iterator autoIter = autoList.begin();
00039 autoIter != autoList.end(); (++autoIter, ++i)) {
00040 const ::SctApi::AutoConf::AutoResult &autoResult = *autoIter;
00041
00042 Sct_SctApi::AutoConfigResult res;
00043
00044 res.partition = autoResult.partition;
00045 res.crate = autoResult.crate;
00046 res.rod = autoResult.rod;
00047
00048 res.tx = autoResult.tx;
00049 res.rx = autoResult.rx;
00050
00051 (*result)[i] = res;
00052 }
00053
00054 return result;
00055 }
00056
00057
00058 template <typename ILUBlock, typename ArrayMember>
00059 inline std::vector<ArrayMember> copyCorbaToVector(const ILUBlock & thisSeq) {
00060 std::vector<ArrayMember> array;
00061
00062 for(unsigned int i=0; i<thisSeq.length(); ++i) {
00063 const ArrayMember am = thisSeq[i];
00064 array.push_back(am);
00065 }
00066
00067 return array;
00068 }
00069
00070
00071 template<>
00072 inline std::vector<std::string> copyCorbaToVector<Sct_SctApi::NameList, std::string>(const Sct_SctApi::NameList & thisSeq) {
00073 std::vector<std::string> array;
00074
00075 for(unsigned int i=0; i<thisSeq.length(); ++i) {
00076 const std::string am = thisSeq[i]._NP_ref();
00077 array.push_back(am);
00078 }
00079
00080 return array;
00081 }
00082
00083
00084 Sct_SctApi::NameValueList * copyMapToNameValueList(std::map<std::string, float> myNameValues) {
00085 Sct_SctApi::NameValueList * result = ::Sct::SequenceUtils::newSafeSequence<Sct_SctApi::NameValueList>(myNameValues.size());
00086
00087
00088
00089
00090 unsigned int i=0;
00091 for(std::map<std::string, float>::const_iterator iter=myNameValues.begin();
00092 iter != myNameValues.end();
00093 (++iter,++i)) {
00094
00095 Sct_SctApi::NameValue member;
00096
00097 member.name = CORBA::string_dup(iter->first.c_str());
00098 member.value = iter->second;
00099
00100 (*result)[i] = member;
00101 }
00102
00103 return result;
00104 }
00105
00106 #endif