00001 #ifndef SCTAPI_MARSHALLING_H
00002 #define SCTAPI_MARSHALLING_H
00003
00004 #include <vector>
00005
00006 Sct_SctApi_T_BOCChannelList copyBOCChannelConfigVectorToILU(const std::vector<SctConfiguration::BOCChannelConfig> &configList) {
00007 Sct_SctApi_T_BOCChannelList result;
00008 result = _Sct_SctApi_T_BOCChannelList_sequence::Create(4, NULL);
00009 result->Clear(0);
00010
00011 for(unsigned long i=0; i<configList.size(); i++) {
00012 const SctConfiguration::BOCChannelConfig &config = configList[i];
00013
00014 sctConf_T_BOCChannelConfig *res = new sctConf_T_BOCChannelConfig;
00015 res->current = config.current;
00016 res->delay = config.delay;
00017 res->markSpace = config.markSpace;
00018
00019 res->threshold0 = config.threshold0;
00020 res->delay0 = config.delay0;
00021
00022 res->threshold1 = config.threshold1;
00023 res->delay1 = config.delay1;
00024 result->Append(res);
00025 }
00026
00027 return result;
00028 }
00029
00030 Sct_SctApi_T_AutoResultList copyAutoResultListToILU(const std::list< ::SctApi::AutoConf::AutoResult> &autoList) {
00031 Sct_SctApi_T_AutoResultList result;
00032 result = _Sct_SctApi_T_AutoResultList_sequence::Create(4, NULL);
00033 result->Clear(0);
00034
00035 for(std::list< ::SctApi::AutoConf::AutoResult>::const_iterator autoIter = autoList.begin();
00036 autoIter != autoList.end(); autoIter ++) {
00037 const ::SctApi::AutoConf::AutoResult &autoResult = *autoIter;
00038
00039 Sct_SctApi_T_AutoConfigResult *res = new Sct_SctApi_T_AutoConfigResult;
00040 res->partition = autoResult.partition;
00041 res->crate = autoResult.crate;
00042 res->rod = autoResult.rod;
00043
00044 res->tx = autoResult.tx;
00045 res->rx = autoResult.rx;
00046
00047 result->Append(res);
00048 }
00049
00050 return result;
00051 }
00052
00053 template <typename ILUBlock, typename ArrayMember>
00054 inline std::vector<ArrayMember> copyILUToVector(ILUBlock thisSeq) {
00055 std::vector<ArrayMember> array;
00056
00057 for(unsigned int i=0; i<thisSeq->Length(); i++) {
00058 array.push_back(thisSeq->Nth(i));
00059 }
00060
00061 return array;
00062 }
00063
00064 Sct_SctApi_T_NameValueList copyMapToNameValueList(std::map<std::string, float> myNameValues) {
00065 Sct_SctApi_T_NameValueList result;
00066
00067 result = _Sct_SctApi_T_NameValueList_sequence::Create(4, NULL);
00068 result->Clear(0);
00069
00070 for(std::map<std::string, float>::const_iterator iter=myNameValues.begin();
00071 iter != myNameValues.end();
00072 iter++) {
00073 Sct_SctApi_T_NameValue *member = new Sct_SctApi_T_NameValue;
00074
00075 char *copy = (char *)malloc((iter->first.length()+1) * sizeof(char));
00076 strncpy(copy, iter->first.c_str(), iter->first.length());
00077 copy[iter->first.length()] = 0;
00078
00079 member->name = copy;
00080 member->value = iter->second;
00081
00082 result->Append(member);
00083 }
00084
00085 return result;
00086 }
00087
00088 #endif