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