]> Creatis software - creaMiniTools.git/blob - bbtk_package_creaMiniTools/src/bbcreaMiniToolsCreateReport01.cxx
8827c1019d4496644db5f715a975fb8360d924f2
[creaMiniTools.git] / bbtk_package_creaMiniTools / src / bbcreaMiniToolsCreateReport01.cxx
1 //===== 
2 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
3 //===== 
4 #include "bbcreaMiniToolsCreateReport01.h"
5 #include "bbcreaMiniToolsPackage.h"
6 namespace bbcreaMiniTools
7 {
8
9 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMiniTools,CreateReport01)
10 BBTK_BLACK_BOX_IMPLEMENTATION(CreateReport01,bbtk::AtomicBlackBox);
11 //===== 
12 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
13 //===== 
14 void CreateReport01::Process()
15 {
16
17 // THE MAIN PROCESSING METHOD BODY
18 //   Here we simply set the input 'In' value to the output 'Out'
19 //   And print out the output value
20 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
21 //    void bbSet{Input|Output}NAME(const TYPE&)
22 //    const TYPE& bbGet{Input|Output}NAME() const 
23 //    Where :
24 //    * NAME is the name of the input/output
25 //      (the one provided in the attribute 'name' of the tag 'input')
26 //    * TYPE is the C++ type of the input/output
27 //      (the one provided in the attribute 'type' of the tag 'input')
28 //    bbSetOutputOut( bbGetInputIn() );
29 //    std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
30       
31     bbSetOutputLstTitles( bbGetInputLstTitles1() );
32     
33     std::vector<std::string> lstPatients    = bbGetInputLstPatientsID();
34     std::vector<std::string> lstTitles1     = bbGetInputLstTitles1();
35     std::vector<std::string> lstTitles2     = bbGetInputLstTitles2();
36     std::vector<std::string> lstStepsPath   = bbGetInputLstStepsPath();
37     std::vector<std::string> lstCommentsPath= bbGetInputLstCommentsPath();
38
39     std::vector<std::string> lstOut00;
40     std::vector<std::string> lstOut01;
41     std::vector<std::string> lstOut02;
42     std::vector<std::string> lstOut03;
43     std::vector<std::string> lstOut04;
44     std::vector<std::string> lstOut05;
45     std::vector<std::string> lstOut06;
46     std::vector<std::string> lstOut07;
47     std::vector<std::string> lstOut08;
48     std::vector<std::string> lstOut09;
49     std::vector<std::string> lstOut10;
50     std::vector<std::string> lstOut11;
51     std::vector<std::string> lstOut12;
52     std::vector<std::string> lstOut13;
53     std::vector<std::string> lstOut14;
54     std::vector<std::string> lstOut15;
55
56     std::vector< std::vector<std::string>* > pLstOut;
57     
58     pLstOut.push_back( &lstOut00 );
59     pLstOut.push_back( &lstOut01 );
60     pLstOut.push_back( &lstOut02 );
61     pLstOut.push_back( &lstOut03 );
62     pLstOut.push_back( &lstOut04 );
63     pLstOut.push_back( &lstOut05 );
64     pLstOut.push_back( &lstOut06 );
65     pLstOut.push_back( &lstOut07 );
66     pLstOut.push_back( &lstOut08 );
67     pLstOut.push_back( &lstOut09 );
68     pLstOut.push_back( &lstOut10 );
69     pLstOut.push_back( &lstOut11 );
70     pLstOut.push_back( &lstOut12 );
71     pLstOut.push_back( &lstOut13 );
72     pLstOut.push_back( &lstOut14 );
73     pLstOut.push_back( &lstOut15 );
74
75
76     int iTitle2,sizeTitles2     = lstTitles2.size();
77     for (iTitle2=0 ; iTitle2<sizeTitles2 ; iTitle2++ )
78     {
79         pLstOut[iTitle2]->push_back( lstTitles2[iTitle2]  );
80         pLstOut[iTitle2]->push_back( " " );
81     } // for iTitle2
82     
83
84     int id;
85     int i,sizeLstPatientsID     = lstPatients.size();
86     int j,sizeLstStepsPath      = lstStepsPath.size();
87     int jj,sizeLstCommentsPath  = lstCommentsPath.size();
88     std::string stdPATIENT("<PATIENT>");
89     std::string pathFile;
90     FILE *ff;
91     char tmpTitle[255];
92     char tmpValue[255];
93     for ( i=0 ;  i<sizeLstPatientsID ; i++ )
94     {
95         pLstOut[0]->push_back( lstPatients[i] );
96         pLstOut[0]->push_back( " " );
97         pLstOut[0]->push_back( " " );
98         pLstOut[0]->push_back( " " );
99         pLstOut[0]->push_back( " " );
100
101         for (j=0; j<sizeLstStepsPath;j++)
102         {
103             id=j+1;
104             pathFile    = lstStepsPath[j];
105             size_t pos  = 0;
106             pos         = pathFile.find( stdPATIENT , pos);
107             pathFile.replace(pos, stdPATIENT.length(), lstPatients[i] );
108             printf("CreateReport01::Process Steps %s \n", pathFile.c_str() );
109             ff=fopen(pathFile.c_str(), "r");
110             strcpy(tmpValue,"?EED?");
111             if (ff!=NULL)
112             {
113                 fscanf(ff,"%s ",tmpTitle);                 // User
114                 fscanf(ff,"%s ",tmpValue);                 //
115                 pLstOut[id]->push_back( tmpValue );
116                 fscanf(ff,"%s ",tmpTitle);                 // State
117                 fscanf(ff,"%s ",tmpValue);                 //
118                 pLstOut[id]->push_back( tmpValue );
119                 fscanf(ff,"%s ",tmpTitle);                 // Date
120                 fscanf(ff,"%s ",tmpValue);                 //
121                 pLstOut[id]->push_back( tmpValue );
122                 fscanf(ff,"%s ",tmpTitle);                 // Time
123                 fscanf(ff,"%s ",tmpValue);                 //
124                 pLstOut[id]->push_back( tmpValue );
125                 pLstOut[id]->push_back( " " );
126                 fclose(ff);
127             } else {
128                 pLstOut[id]->push_back( " " );
129                 pLstOut[id]->push_back( " " );
130                 pLstOut[id]->push_back( " " );
131                 pLstOut[id]->push_back( " " );
132                 pLstOut[id]->push_back( " " );
133             }// if ff
134         } // for j
135
136         for ( jj=0; jj<sizeLstCommentsPath ; jj++ )
137         {
138             id=jj+1+sizeLstStepsPath;
139
140             pathFile    = lstCommentsPath[jj];
141             size_t pos  = 0;
142             pos         = pathFile.find( stdPATIENT , pos);
143             pathFile.replace(pos, stdPATIENT.length(), lstPatients[i] );
144             printf("CreateReport01::Process comments %s \n", pathFile.c_str() );
145             ff=fopen(pathFile.c_str(), "r");
146             strcpy(tmpValue,"?EED?");
147             if (ff!=NULL)
148             {
149                 fgets(tmpValue,255,ff);
150                 printf("tmpValue %s \n",tmpValue);
151                 pLstOut[id]->push_back( tmpValue );
152                 pLstOut[id]->push_back( " " );
153                 pLstOut[id]->push_back( " " );
154                 pLstOut[id]->push_back( " " );
155                 pLstOut[id]->push_back( " " );
156                 fclose(ff);
157             } else {
158                 pLstOut[id]->push_back( "? " );
159                 pLstOut[id]->push_back( "? " );
160                 pLstOut[id]->push_back( "? " );
161                 pLstOut[id]->push_back( "? " );
162                 pLstOut[id]->push_back( "? " );
163             }// if ff
164         } // for j
165
166     } // for i
167     
168     bbSetOutputOut00( lstOut00 );
169     bbSetOutputOut01( lstOut01 );
170     bbSetOutputOut02( lstOut02 );
171     bbSetOutputOut03( lstOut03 );
172     bbSetOutputOut04( lstOut04 );
173     bbSetOutputOut05( lstOut05 );
174     bbSetOutputOut06( lstOut06 );
175     bbSetOutputOut07( lstOut07 );
176     bbSetOutputOut08( lstOut08 );
177     bbSetOutputOut09( lstOut09 );
178     bbSetOutputOut10( lstOut10 );
179     bbSetOutputOut11( lstOut11 );
180     bbSetOutputOut12( lstOut12 );
181     bbSetOutputOut13( lstOut13 );
182     bbSetOutputOut14( lstOut14 );
183     bbSetOutputOut15( lstOut15 );
184 }
185 //===== 
186 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
187 //===== 
188 void CreateReport01::bbUserSetDefaultValues()
189 {
190
191 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
192 //    Here we initialize the input 'In' to 0
193 //   bbSetInputIn(0);
194   
195 }
196 //===== 
197 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
198 //===== 
199 void CreateReport01::bbUserInitializeProcessing()
200 {
201
202 //  THE INITIALIZATION METHOD BODY :
203 //    Here does nothing 
204 //    but this is where you should allocate the internal/output pointers 
205 //    if any 
206
207   
208 }
209 //===== 
210 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
211 //===== 
212 void CreateReport01::bbUserFinalizeProcessing()
213 {
214
215 //  THE FINALIZATION METHOD BODY :
216 //    Here does nothing 
217 //    but this is where you should desallocate the internal/output pointers 
218 //    if any
219   
220 }
221 }
222 // EO namespace bbcreaMiniTools
223
224