source: main/trunk/greenstone2/runtime-src/src/corba/corbatext_t.mpp@ 28762

Last change on this file since 28762 was 25231, checked in by ak19, 12 years ago

Many changes to get corba working again ever since the addition of RSS support meant that the method get_rss_items needed to be mirrored in the corba code. The corba code was not compiling then and it turned out we needed a later version of Mico's corba implementation (2.3.13 up from 2.3.5). Therefore the current commit not only corrects some errors in the recently added getRssItems() method but includes further changes: 1. namespaced use of iostream functions were required in some mpp files. 2. New types and member variables added to the corbaiface.idl interface file, to mirror the presence of equivalent variables in comtools.h which hadn't been ported over yet. (Such as the complex corba data type equivalent of collectionmetamap used in comtools.h.) This required (de)serialisation methods to be declared and implemented in corbatext_t.h and corbatext_t.mpp. The additional member variables for the corbaColInfoResponse in corbaiface.idl are now also unpacked in corbaproto.mpp along with the rest of the data structure. 3. Having changed from mico version 2.3.5 to 2.3.13 required code to changed to use POA instead of BOA. This also meant that skeleton files were no longer to be generated when running idl over corbaiface.idl. corbaserver inherits from a POA related object now instead of from the skeleton. 4. Makefile.in was updated to reflect these changes (absence of skeleton), includes a target to run IDL over the corbaiface.idl file to generate the necessary helper files, and corrects earlier oversights in updating the corba makefile with the rest of the changes made over time to runtime-src.

  • Property svn:keywords set to Author Date Id Revision
File size: 5.1 KB
Line 
1// standard headers
2#if defined(GSDL_USE_STL_H)
3#include <iostream.h>
4#include <fstream.h>
5#include <vector.h>
6#else
7#include <iostream>
8#include <fstream>
9#include <vector>
10#endif
11
12// protocol headers
13#include "corbaiface.h"
14using namespace gsdlInterface;
15
16// greenstone headers
17#include "corbaconv_text_t.h"
18
19//local headers
20#include "corbatext_t.h"
21
22void corbatext_fillChar(corbatext_t *t, char *text)
23{
24 unsigned int i;
25
26 t->text.length(0);
27 if (text == NULL)
28 {
29 return;
30 }
31 for (i = 0; i < strlen(text); i ++)
32 {
33 t->text[i] = text[i];
34 }
35 t->encoding = 0;
36}
37
38void corbatext_usvector(corbatext_t t, usvector& us)
39{
40 unsigned int i;
41
42 for (i = 0; i < t.text.length(); i ++)
43 {
44 us.push_back(t.text[i]);
45 }
46}
47
48char *corbatext_string(corbatext_t t)
49{
50 char *lcopy;
51 unsigned int i;
52 lcopy = (char *) malloc(t.text.length() + 1);
53 for (i = 0; i < t.text.length(); i ++)
54 {
55 lcopy[i] = (char) t.text[i];
56 }
57 lcopy[i] = '\0';
58 return lcopy;
59}
60
61corbatext_t_var corbatext_corbatext(text_t t)
62{ corbatext_t_var ct;
63// usString_var us;
64
65 // cout << "Making text\n";
66 ct = new corbatext_t;
67 // ct->text.length(20);
68 // us = new usString(20);
69 // cout << ct->text.length() << endl;
70 // cout << ct->text.maximum() << endl;
71 corbaconv_text_t::fillUsString(t,&ct->text);
72 //t.fillUsString(us);
73 // delete us;
74 // cout << "Encoding text\n";
75 ct->encoding = 0;
76 // cout << "Encoding text\n";
77 return ct;
78}
79
80int corbatext_corbatext(text_t t, corbatext_t_var ct)
81{
82 cout << "A" << endl;
83 corbaconv_text_t::fillUsString(t,&ct->text);
84 cout << "B" << endl;
85 ct->encoding = 0;
86 cout << "C" << endl;
87
88 return 0;
89}
90
91void corbatext_corbaArrayToArray(corbatext_tarray ca, text_tarray *ta)
92{
93 unsigned int i;
94 corbaconv_text_t *cct;
95
96 ta->clear();
97 ta->reserve(ca.length());
98 for (i = 0; i < ca.length(); i ++)
99 {
100 cct = new corbaconv_text_t(ca[i]);
101 ta->push_back(*cct); // cast to text_t
102 }
103}
104
105void corbatext_arrayToCorbaArray(text_tarray ta, corbatext_tarray *_ca)
106{
107 text_tarray::iterator here = ta.begin();
108 text_tarray::iterator end = ta.end();
109 corbatext_tarray ca(end - here);
110 unsigned int i;
111
112 i = 0;
113 (*_ca).length(end - here);
114
115 while (here != end)
116 {
117 corbatext_t_var ptr;
118 // cout << "Array: " << (*_ca).maximum() << " " << (*_ca).length() << endl;
119 ptr = corbatext_corbatext(*here);
120 (*_ca)[i] = ptr;
121 here ++;
122 i++;
123 }
124}
125
126void corbatext_corbaArrayToSet(corbatext_tarray t, text_tset *ts)
127{ unsigned int i;
128
129 for (i = 0; i < t.length(); i ++)
130 {
131 ts->insert((corbaconv_text_t) t[i]); // further typecast to text_t
132 }
133
134 return;
135}
136
137void corbatext_setToCorbaArray(text_tset ts, corbatext_tarray *t)
138{
139 corbatext_t str;
140 text_tset::iterator here = ts.begin();
141 text_tset::iterator end = ts.end();
142 unsigned int i;
143
144 i = 0;
145 while (here != end)
146 {
147 (*t).length(i+1);
148 (*t)[i] = *corbatext_corbatext(*here);
149 here ++;
150 i ++;
151 }
152}
153
154void corbatext_mapToCorbaMap(text_tmap map, corbatext_tmap *cmap)
155{
156 text_tmap::iterator here = map.begin();
157 text_tmap::iterator end = map.end();
158 unsigned int i = 0;
159
160 while (here != end)
161 {
162 (*cmap).names.length(i+1);
163 (*cmap).values.length(i+1);
164 cmap->names[i] = *corbatext_corbatext((*here).first);
165 cmap->values[i] = *corbatext_corbatext((*here).second);
166 here ++;
167 i ++;
168 }
169}
170
171void corbatext_corbaMapToMap(corbatext_tmap cmap, text_tmap &map)
172{
173 unsigned int i;
174
175 for (i = 0; i < cmap.names.length(); i ++)
176 {
177 map.insert(make_pair(*(new corbaconv_text_t(cmap.names[i])),
178 *(new corbaconv_text_t(cmap.values[i])))); // further typecast to text_t
179 }
180}
181
182
183// map of metanames to array(lang, value). So each metaname[i] maps to array (lang, value).
184// Note that corbacollectionmeta_map is an array of pairs
185// each pair consists of (string, map)
186void corbatext_colmetamapToCorbaColmetamap(collectionmeta_map cm, corbatext_tcollectionmeta_map *ccm)
187{
188 collectionmeta_map::iterator here = cm.begin();
189 collectionmeta_map::iterator end = cm.end();
190 unsigned int i = 0;
191
192 while (here != end)
193 {
194 ccm->length(i+1); // increase size of array of (name, tuples) pairs by 1 each time
195
196 // fill in the metaname field
197 // metaname is of type text_t, get the corbatext value for the text_t key
198 (*ccm)[i].name = *corbatext_corbatext((*here).first); // metaname is of type text_t
199
200 // fill in the tuples field
201 corbatext_mapToCorbaMap((*here).second, &((*ccm)[i].tuples));
202
203 here ++;
204 i ++;
205 }
206
207}
208
209void corbatext_corbaColmetamapToColmetamap(corbatext_tcollectionmeta_map ccm, collectionmeta_map &cm)
210{
211 unsigned int i;
212
213 for (i = 0; i < ccm.length(); i ++)
214 {
215 // ccm is an array
216 // where each element is a pair of (name, tuples)
217
218 // 1. get the (corba_text_t) name and convert it to text_t
219 text_t* meta_name = new corbaconv_text_t(ccm[i].name);
220
221 corbatext_tmap corbameta_tuples = ccm[i].tuples;
222
223 text_tmap *tuples_map = new text_tmap();
224 corbatext_corbaMapToMap(ccm[i].tuples, *tuples_map);
225
226
227 cm.insert(make_pair(*meta_name,
228 *tuples_map));
229 }
230}
231
Note: See TracBrowser for help on using the repository browser.