Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Related Pages

ILUMarshalling.h

00001 #ifndef SCT_ILUMARSHALLING_H
00002 #define SCT_ILUMARSHALLING_H
00003 
00004 #include <list>
00005 #include <string>
00006 #include <vector>
00007 
00008 namespace Sct {
00009     
00016 inline ilu_T_CString copyStringToILU(std::string str) {
00017     char *copy = (char *)malloc((str.length()+1) * sizeof(char));
00018     strncpy(copy, str.c_str(), str.length());
00019     copy[str.length()] = 0;
00020     return copy;
00021 }
00022 
00023 template <typename ILUSequence, typename ListMember>
00024 inline ILUSequence *copyListToILU(std::list<ListMember> thisList) {
00025   ILUSequence *result;
00026 
00027   result = ILUSequence::Create(4, NULL);
00028   result->Clear(0);
00029 
00030   for(typename std::list<ListMember>::const_iterator m = thisList.begin();
00031       m!=thisList.end();
00032       m++) {
00033     result->Append(*m);
00034   }
00035 
00036   return result;
00037 }
00038 
00039 template <typename ILUSequence>
00040 inline ILUSequence *copyStringListToILU(std::list<std::string> thisList) {
00041   ILUSequence *result;
00042 
00043   result = ILUSequence::Create(4, NULL);
00044   result->Clear(0);
00045 
00046   for(std::list<std::string>::const_iterator m = thisList.begin();
00047       m!=thisList.end();
00048       m++) {
00049     char *copy = (char *)malloc((m->length()+1) * sizeof(char));
00050     strncpy(copy, m->c_str(), m->length());
00051     copy[m->length()] = 0;
00052     result->Append(copy);
00053   }
00054 
00055   return result;
00056 }
00057 
00058 template <typename ILUSequence, typename ListMember>
00059 inline std::list<ListMember> copyILUToList(ILUSequence* thisSeq) {
00060   std::list<ListMember> result;
00061 
00062   if (thisSeq) {
00063       for(unsigned int i=0; i<thisSeq->Length(); i++) {
00064       result.push_back(thisSeq->Nth(i));
00065       }
00066   }
00067 
00068   return result;
00069 }
00070 
00071 
00072 template <typename ILUSequence, typename List>
00073 inline List copyILUToStdCollection(ILUSequence* thisSeq) {
00074   List result;
00075 
00076   if (thisSeq) {
00077       for(unsigned int i=0; i<thisSeq->Length(); i++) {
00078           result.push_back(thisSeq->Nth(i));
00079       }
00080   }
00081 
00082   return result;
00083 }
00084 
00085 
00086 template <typename ILUSequence, typename ArrayMember>
00087 inline ILUSequence *copyArrayToILU(ArrayMember *array, unsigned long length) {
00088   ILUSequence *result;
00089 
00090   result = ILUSequence::Create(4, NULL);
00091   result->Clear(0);
00092 
00093   if(array) {
00094     for(unsigned long i=0; i<length; i++) {
00095       result->Append(array[i]);
00096     }
00097   }
00098 
00099   return result;
00100 }
00101 
00102 template <typename ILUSequence, typename ArrayMember>
00103 inline ILUSequence *copyVectorToILU(std::vector<ArrayMember> array) {
00104   ILUSequence *result;
00105 
00106   result = ILUSequence::Create(4, NULL);
00107   result->Clear(0);
00108 
00109   for(unsigned long i=0; i<array.size(); i++) {
00110     result->Append(array[i]);
00111   }
00112 
00113   return result;
00114 }
00115 
00116 template <typename ILUMatrix, typename ILUSequence, typename ArrayMember>
00117 inline ILUMatrix *copyVectorVectorToILU(std::vector<std::vector<ArrayMember> > matrix) {
00118   ILUMatrix *result;
00119 
00120   result = ILUMatrix::Create(4, NULL);
00121   result->Clear(0);
00122 
00123   for(unsigned long i=0; i<matrix.size(); i++) {
00124     ILUSequence *seq = ILUSequence::Create(4, NULL);
00125     seq->Clear(0);
00126     for(unsigned long j=0; j<matrix[i].size(); j++) {
00127       seq->Append(matrix[i][j]);
00128     }
00129     result->Append(seq);
00130   }
00131 
00132   return result;
00133 }
00134 
00135 template <typename ILUBlock, typename ArrayMember>
00136 inline ArrayMember *copyILUToArray(ILUBlock thisSeq, ArrayMember *array, size_t length) {
00137   assert(thisSeq->Length() == length);
00138   for(unsigned int i=0; i<length; i++) {
00139     array[i] = thisSeq->Nth(i);
00140   }
00141 
00142   return array;
00143 }
00144   
00145   
00146 }
00147 
00148 
00149 #endif //SCT_ILUMARSHALLING_H

Generated on Thu Jul 15 09:50:46 2004 for SCT DAQ/DCS Software - C++ by doxygen 1.3.5