summaryrefslogtreecommitdiffstats
path: root/catalogmgr/typefactory.cc
blob: 80fee7a7c7a0d34256d253a1aed092fcf2e66ca7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
/*
* This file is part of rasdaman community.
*
* Rasdaman community is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Rasdaman community is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with rasdaman community.  If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann /
rasdaman GmbH.
*
* For more information please see <http://www.rasdaman.org>
* or contact Peter Baumann via <baumann@rasdaman.com>.
/
// This is -*- C++ -*-
/*************************************************************************
 *
 *
 * PURPOSE:
 *
 *
 * COMMENTS:
 *   uses embedded SQL
 *
 ***********************************************************************/

static const char rcsid[] = "@(#)catalogif,TypeFactory: $Header: /home/rasdev/CVS-repository/rasdaman/catalogmgr/typefactory.cc,v 1.19 2003/12/20 23:41:27 rasdev Exp $";

#include <vector>
#include <algorithm>
#include <map>
#include <utility>
#include <set>

#include "raslib/rminit.hh"
#include "raslib/rmdebug.hh"
#include "relcatalogif/alltypes.hh"
#include "typefactory.hh"
#include "reladminif/objectbroker.hh"
#include "reladminif/adminif.hh"
#include "reladminif/databaseif.hh"
#include "reladminif/sqlerror.hh"
#include "reladminif/externs.h"
#include "reladminif/dbref.hh"
#include "relcatalogif/dbminterval.hh"
#include "relmddif/mddid.hh"
#include "relmddif/dbmddobj.hh"
#include "relmddif/dbmddset.hh"

TypeFactory* TypeFactory::myInstance = 0;

const short TypeFactory::MaxBuiltInId = 11;

const char* OctetType::Name = "Octet";
const char* UShortType::Name = "UShort";
const char* ShortType::Name = "Short";
const char* ULongType::Name = "ULong";
const char* LongType::Name = "Long";
const char* BoolType::Name = "Bool";
const char* CharType::Name = "Char";
const char* FloatType::Name = "Float";
const char* DoubleType::Name = "Double";
const char* ComplexType1::Name = "Complex1";
const char* ComplexType2::Name = "Complex2";

using namespace std;

// all atomic types given back by mapType()
// for managing the memory of temporary types
std::vector<Type*> *TypeFactory::theTempTypes = 0;

TypeFactory* 
TypeFactory::instance()
	{
	if(myInstance == 0)
		{
		myInstance = new TypeFactory;
		}
	return myInstance;
	}

const BaseType*
TypeFactory::mapType(const char* typeName)
	{
	RMDBGENTER(4, RMDebug::module_catalogmgr, "TypeFactory", "mapType(" << typeName << ")");
	BaseType* resultType = 0;
	resultType = (BaseType*)ObjectBroker::getObjectByName(OId::ATOMICTYPEOID, typeName);
	if (resultType == 0)
		{
		try	{
			resultType = (BaseType*)ObjectBroker::getObjectByName(OId::STRUCTTYPEOID, typeName);
			}
		catch	(r_Error)
			{
			resultType = 0;
			}
		}
	RMDBGEXIT(4, RMDebug::module_catalogmgr, "TypeFactory", "mapType(" << typeName << ") END " << resultType);
	return resultType;
	}

const StructType*
TypeFactory::addStructType(const StructType* type)
	{
	RMDBGENTER(4, RMDebug::module_catalogmgr, "TypeFactory", "addStructType(" << type->getTypeName() << ")");
	StructType* persistentType = 0;
	const StructType* retval = 0;
	if (type->isPersistent())
		{
		RMDBGMIDDLE(5, RMDebug::module_catalogmgr, "TypeFactory", "type is persistent " << type->getName() << " " << type->getOId());
		retval = type;
		}
	else	{
		persistentType = new StructType((char*)type->getTypeName(), type->getNumElems());
		BaseType* t = 0;
		for (int i = 0; i < type->getNumElems(); i++)
			{
			switch (type->getElemType(i)->getType())
				{
				case STRUCT:
					RMDBGMIDDLE(6, RMDebug::module_catalogmgr, "TypeFactory", "element is struct type " << (char*)type->getElemName(i) << " of type " << type->getElemType(i)->getName());
					persistentType->addElement(type->getElemName(i), addStructType((const StructType*)type->getElemType(i)));
					break;
				case ULONG:
				case USHORT:
				case CHAR:
				case BOOLTYPE:
				case LONG:
				case SHORT:
				case OCTET:
				case DOUBLE:
				case FLOAT:
				case COMPLEXTYPE1:
				case COMPLEXTYPE2:
					RMDBGMIDDLE(6, RMDebug::module_catalogmgr, "TypeFactory", "element is atomic type " << (char*)type->getElemName(i) << " of type " << type->getElemType(i)->getName());
					persistentType->addElement(type->getElemName(i), (BaseType*)ObjectBroker::getObjectByOId(type->getElemType(i)->getOId()));
					break;
				default:
					persistentType = 0;
					RMDBGMIDDLE(0, RMDebug::module_catalogmgr, "TypeFactory", "addStructType(" << type->getTypeName() << ") unknown type " << type->getOId() << type->getOId().getType());
					break;
				}
			}
		RMDBGMIDDLE(5, RMDebug::module_catalogmgr, "TypeFactory", "type is now persistent " << persistentType->getName() << " " << persistentType->getOId());
		persistentType->setCached(true);
		persistentType->setPersistent(true);
		ObjectBroker::registerDBObject(persistentType);
		retval = persistentType;
		}
	RMDBGEXIT(4, RMDebug::module_catalogmgr, "TypeFactory", "addStructType(" << retval->getTypeName() << ") END");
	return retval;
	}

const SetType*
TypeFactory::mapSetType(const char* typeName)
	{
	RMDBGENTER(4, RMDebug::module_catalogmgr, "TypeFactory", "mapSetType(" << typeName << ")");
	// it is a user defined type
	SetType* resultType = 0;
	try	{
		resultType = (SetType*)ObjectBroker::getObjectByName(OId::SETTYPEOID, typeName);
		}
	catch	(r_Error)
		{
		resultType = 0;
		}
	RMDBGEXIT(4, RMDebug::module_catalogmgr, "TypeFactory", "mapSetType(" << typeName << ") END " << resultType);
	return resultType;
	}

const SetType*
TypeFactory::addSetType(const SetType* type)
	{
	RMDBGENTER(4, RMDebug::module_catalogmgr, "TypeFactory", "addSetType(" << type->getTypeName() << ")");
	SetType* persistentType = 0;
	const SetType* retval = 0;
	if (type->isPersistent())
		{
		RMDBGMIDDLE(5, RMDebug::module_catalogmgr, "TypeFactory", "type is persistent " << type->getName() << " " << type->getOId());
		retval = type;
		}
	else	{
		persistentType = new SetType((char*)type->getTypeName(), addMDDType(type->getMDDType()));
		persistentType->setPersistent(true);
		RMDBGMIDDLE(5, RMDebug::module_catalogmgr, "TypeFactory", "type is now persistent " << type->getName() << " " << persistentType->getOId());
		ObjectBroker::registerDBObject(persistentType);
		persistentType->setCached(true);
		retval = persistentType;
		}
	RMDBGEXIT(4, RMDebug::module_catalogmgr, "TypeFactory", "addSetType(" << retval->getTypeName() << ") END");
	return retval;
	}

const MDDType*
TypeFactory::mapMDDType(const char* typeName)
	{
	RMDBGENTER(4, RMDebug::module_catalogmgr, "TypeFactory", "mapMDDType(" << typeName << ")");
	MDDType* resultType = 0;
	try	{
		resultType = ObjectBroker::getMDDTypeByName(typeName);
		}
	catch	(...)
		{
		resultType = 0;
		}
	RMDBGEXIT(4, RMDebug::module_catalogmgr, "TypeFactory", "mapMDDType(" << typeName << ") END " << resultType);
	return resultType;
	}

const MDDType* 
TypeFactory::addMDDType(const MDDType* type)
	{
	RMDBGENTER(4, RMDebug::module_catalogmgr, "TypeFactory", "addMDDType(" << type->getTypeName() << ")");
	MDDType* persistentType = 0;
	const MDDType* retval = 0;
	BaseType* t = 0;

	if (type->isPersistent())
		{
		RMDBGMIDDLE(5, RMDebug::module_catalogmgr, "TypeFactory", "type is persistent " << type->getOId());
		retval = type;
		}
	else	{
		RMDBGMIDDLE(5, RMDebug::module_catalogmgr, "TypeFactory", "type is not persistent " << type->getOId());
		switch (type->getSubtype())
			{
			case MDDType::MDDONLYTYPE:
				RMDBGMIDDLE(7, RMDebug::module_catalogmgr, "TypeFactory", "is MDDONLYTYPE");
				persistentType = new MDDType(type->getTypeName());
				break;
			case MDDType::MDDBASETYPE:
				RMDBGMIDDLE(7, RMDebug::module_catalogmgr, "TypeFactory", "is MDDBASETYPE");
				persistentType = new MDDBaseType(type->getTypeName(), addStructType((StructType*)((MDDBaseType*)type)->getBaseType()));
				break;
			case MDDType::MDDDOMAINTYPE:
				RMDBGMIDDLE(7, RMDebug::module_catalogmgr, "TypeFactory", "is MDDDOMAINTYPE");
				persistentType = new MDDDomainType(type->getTypeName(), addStructType((StructType*)((MDDBaseType*)type)->getBaseType()), *((MDDDomainType*)type)->getDomain());
				break;
			case MDDType::MDDDIMENSIONTYPE:
				RMDBGMIDDLE(7, RMDebug::module_catalogmgr, "TypeFactory", "is MDDDIMENSIONTYPE");
				persistentType = new MDDDimensionType(type->getTypeName(), addStructType((StructType*)((MDDBaseType*)type)->getBaseType()), ((MDDDimensionType*)type)->getDimension());
				break;
			default:
				RMDBGMIDDLE(0, RMDebug::module_catalogmgr, "TypeFactory", "addMDDType(" << type->getName() << ") mddsubtype unknown");
				break;
			}
		if (persistentType != 0)
			{
			persistentType->setPersistent(true);
			RMDBGMIDDLE(6, RMDebug::module_catalogmgr, "TypeFactory", "adding " << persistentType->getName() << " " << persistentType->getOId());
			persistentType->setCached(true);
			ObjectBroker::registerDBObject(persistentType);
			retval = persistentType;
			}
		else	{
			//error message was already given in switch default
			}
		}
	RMDBGEXIT(4, RMDebug::module_catalogmgr, "TypeFactory", "addMDDType(" << type->getTypeName() << ") END");
	return retval;
	}

Type*
TypeFactory::addTempType(Type* type)
	{
	// put in front to avoid deletion of MDDTypes still referenced
	// by an MDDBaseType.
	theTempTypes->insert(theTempTypes->begin(), type);
	return type;
	}

void 
TypeFactory::initialize()
	{
	// to initailize the typefactory
	RMDBGENTER(4, RMDebug::module_catalogmgr, "TypeFactory", "initialize()");
	if (!theTempTypes)
		theTempTypes = new std::vector<Type*>;

	RMDBGEXIT(4, RMDebug::module_catalogmgr, "TypeFactory", "initialize() END");
	}

void
TypeFactory::freeTempTypes()
	{
	RMDBGENTER(4, RMDebug::module_catalogmgr, "TypeFactory", "freeTempTypes()");

	// delete all temporary types
	if (theTempTypes)
		{
		for(std::vector<Type*>::iterator iter = theTempTypes->begin(); iter != theTempTypes->end(); iter++)
			{
			delete *iter;
			*iter = 0;
			}
		delete theTempTypes;
		theTempTypes = 0;
		}
	RMDBGEXIT(4, RMDebug::module_catalogmgr, "TypeFactory", "freeTempTypes()");
	}

TypeFactory::TypeFactory()
	{
	}

void
TypeFactory::deleteStructType(const char* typeName)
	{
	RMDBGENTER(4, RMDebug::module_catalogmgr, "TypeFactory", "deleteStructType(" << typeName << ")");
	const DBObject* resultType = mapType(typeName);
	if (resultType)
		{
		if (resultType->getOId().getCounter() > MaxBuiltInId)
			{//only neccessary to check if the type is in a mdd base/dim/dom type
			bool canDelete = true;
			for (TypeIterator<MDDType> miter = createMDDIter(); miter.not_done(); miter.advance())
				{
				if (miter.get_element()->getSubtype() != MDDType::MDDONLYTYPE)
					{
					if (((MDDBaseType*)(miter.get_element().ptr()))->getBaseType() == resultType)
						{
						RMDBGMIDDLE(5, RMDebug::module_catalogmgr, "TypeFactory", "mdd type " << miter.get_element()->getName() << " contains " << typeName);
						canDelete = false;
						break;
						}
					}
				}
			if (canDelete)
				{
				DBObjectId toKill(resultType->getOId());
				toKill->setPersistent(false);
				toKill->setCached(false);
				RMDBGMIDDLE(5, RMDebug::module_catalogmgr, "TypeFactory", "will be deleted from db");
				}
			else	{
				RMDBGMIDDLE(5, RMDebug::module_catalogmgr, "TypeFactory", "will not be deleted from db");
				}
			}
		else	{
			RMDBGMIDDLE(0, RMDebug::module_catalogmgr, "TypeFactory", "builtin type will not be deleted");
			}
		}
	else	{
		RMDBGMIDDLE(5, RMDebug::module_catalogmgr, "TypeFactory", "is not in map");
		}
	RMDBGEXIT(4, RMDebug::module_catalogmgr, "TypeFactory", "deleteStructType(" << typeName << ")");
	}

void
TypeFactory::deleteMDDType(const char* typeName)
	{
	RMDBGENTER(4, RMDebug::module_catalogmgr, "TypeFactory", "deleteMDDType(" << typeName << ")");
	const MDDType* resultType = mapMDDType(typeName);  //is ok because only short for find
	if (resultType)
		{
		bool canDelete = true;
		for (TypeIterator<SetType> miter = createSetIter(); miter.not_done(); miter.advance())
			{
			if (miter.get_element()->getMDDType() == resultType)
				{
				RMDBGMIDDLE(5, RMDebug::module_catalogmgr, "TypeFactory", "set type " << miter.get_element()->getName() << " contains " << typeName);
				canDelete = false;
				break;
				}
			}
		if (canDelete)
			{
			if (resultType->getSubtype() != MDDType::MDDONLYTYPE)
				{
				//mdd only types can not be in mdd objects
				OIdSet* theList = ObjectBroker::getAllObjects(OId::MDDOID);
				for (OIdSet::iterator miter = theList->begin(); miter != theList->end(); miter++)
					{
					if (DBMDDObjId(*miter)->getMDDBaseType() == resultType)
						{
						RMDBGMIDDLE(5, RMDebug::module_catalogmgr, "TypeFactory", "mdd object " << *miter << " contains " << typeName);
						canDelete = false;
						break;
						}
					}
				delete theList;
				theList = 0;
				}
			if (canDelete)
				{
				DBObjectId toKill(resultType->getOId());
				toKill->setPersistent(false);
				toKill->setCached(false);
				RMDBGMIDDLE(5, RMDebug::module_catalogmgr, "TypeFactory", "will be deleted from db");
				}
			else	{
				RMDBGMIDDLE(5, RMDebug::module_catalogmgr, "TypeFactory", "will not be deleted from db");
				}
			}
		else	{
			RMDBGMIDDLE(5, RMDebug::module_catalogmgr, "TypeFactory", "will not be deleted from db");
			}
		}
	else	{
		RMDBGMIDDLE(5, RMDebug::module_catalogmgr, "TypeFactory", "is not in map");
		}
	RMDBGEXIT(4, RMDebug::module_catalogmgr, "TypeFactory", "deleteMDDType(" << typeName << ") END");
	}

void
TypeFactory::deleteSetType(const char* typeName)
	{
	RMDBGENTER(4, RMDebug::module_catalogmgr, "TypeFactory", "deleteSetType(" << typeName << ")");
	const DBObject* resultType = (SetType*)mapSetType(typeName);//is ok because only short for find
	if (resultType)
		{
		bool canDelete = true;
		OIdSet* theList = ObjectBroker::getAllObjects(OId::MDDCOLLOID);
		for (OIdSet::iterator miter = theList->begin(); miter != theList->end(); miter++)
			{
			if (DBMDDSetId(*miter)->getCollType() == resultType)
				{
				RMDBGMIDDLE(5, RMDebug::module_catalogmgr, "TypeFactory", "set object " << *miter << " contains " << typeName);
				canDelete = false;
				break;
				}
			}
		delete theList;
		theList = 0;
		if (canDelete)
			{
			DBObjectId toKill(resultType->getOId());
			toKill->setPersistent(false);
			toKill->setCached(false);
			RMDBGMIDDLE(5, RMDebug::module_catalogmgr, "TypeFactory", "will be deleted from db");
			}
		else	{
			RMDBGMIDDLE(5, RMDebug::module_catalogmgr, "TypeFactory", "will not be deleted from db");
			}
		}
	else	{
		RMDBGMIDDLE(5, RMDebug::module_catalogmgr, "TypeFactory", "is not in map");
		}
	RMDBGEXIT(4, RMDebug::module_catalogmgr, "TypeFactory", "deleteSetType(" << typeName << ") END");
	}

const Type*
TypeFactory::ensurePersistence(Type* type)
	{
	std::vector<Type*>::iterator iter;
	const Type* retval = 0;
	Type* ttype = 0;

	// deleting type if it is in the list of tempTypes
	if(theTempTypes)
		{
		for(iter = theTempTypes->begin(); iter < theTempTypes->end(); iter++)
			{
			if(*iter == type)
				{
				theTempTypes->erase(iter);
				}
			}
		}
	// check if the struct type is alread in the DBMS
	switch (type->getType())
		{
		case STRUCT:
			{
			TypeIterator<StructType> ist = createStructIter();
			while (ist.not_done())
				{
				ttype = ist.get_element();
				if (ttype->compatibleWith(type))
					{
					retval = ttype;
					break;
					}
				ist.advance();
				}
			if (!retval)
				retval = addStructType((const StructType*)type);
			}
			break;
		case MDDTYPE:
			{
			TypeIterator<MDDType> imd = createMDDIter();
			while (imd.not_done())
				{
				ttype = imd.get_element();
				if (ttype->compatibleWith(type))
					{
					retval = ttype;
					break;
					}
				imd.advance();
				}
			if (!retval)
				retval = addMDDType((const MDDType*)type);
			}
			break;
		case SETTYPE:
			{
			TypeIterator<SetType> ise = createSetIter();
			while (ise.not_done())
				{
				ttype = ise.get_element();
				if (ttype->compatibleWith(type))
					{
					retval = ttype;
					break;
					}
				ise.advance();
				}
			if (!retval)
				retval = addSetType((const SetType*)type);
			}
			break;
		case ULONG:
			retval = (Type*)ObjectBroker::getObjectByOId(OId(ULONG, OId::ATOMICTYPEOID));
			break;
		case USHORT:
			retval = (Type*)ObjectBroker::getObjectByOId(OId(USHORT, OId::ATOMICTYPEOID));
			break;
		case CHAR:
			retval = (Type*)ObjectBroker::getObjectByOId(OId(CHAR, OId::ATOMICTYPEOID));
			break;
		case BOOLTYPE:
			retval = (Type*)ObjectBroker::getObjectByOId(OId(BOOLTYPE, OId::ATOMICTYPEOID));
			break;
		case LONG:
			retval = (Type*)ObjectBroker::getObjectByOId(OId(LONG, OId::ATOMICTYPEOID));
			break;
		case SHORT:
			retval = (Type*)ObjectBroker::getObjectByOId(OId(SHORT, OId::ATOMICTYPEOID));
			break;
		case OCTET:
			retval = (Type*)ObjectBroker::getObjectByOId(OId(OCTET, OId::ATOMICTYPEOID));
			break;
		case DOUBLE:
			retval = (Type*)ObjectBroker::getObjectByOId(OId(DOUBLE, OId::ATOMICTYPEOID));
			break;
		case FLOAT:
			retval = (Type*)ObjectBroker::getObjectByOId(OId(FLOAT, OId::ATOMICTYPEOID));
			break;
		case COMPLEXTYPE1:
			retval = (Type*)ObjectBroker::getObjectByOId(OId(COMPLEXTYPE1, OId::ATOMICTYPEOID));
			break;
		case COMPLEXTYPE2:
			retval = (Type*)ObjectBroker::getObjectByOId(OId(COMPLEXTYPE2, OId::ATOMICTYPEOID));
			break;
 		default:
			RMDBGONCE(0, RMDebug::module_catalogmgr, "TypeFactory", "ensurePersitence() is not a STRUCT/MDDTYPE/SETTYPE/ATOMIC " << type->getName());
			break;
		}
	if (!type->isPersistent())
		delete type;
	return retval;
	}

TypeIterator<SetType>
TypeFactory::createSetIter()
	{
	RMDBGONCE(1, RMDebug::module_catalogmgr, "TypeFactory", "createSetIter()");
	OIdSet* t = ObjectBroker::getAllObjects(OId::SETTYPEOID);
	TypeIterator<SetType> ti(*t);
	delete t;
	t = 0;
	return ti;
	}

TypeIterator<StructType>
TypeFactory::createStructIter()
	{
	RMDBGONCE(1, RMDebug::module_catalogmgr, "TypeFactory", "createStructIter()");
	OIdSet* t = ObjectBroker::getAllObjects(OId::STRUCTTYPEOID);
	TypeIterator<StructType> ti(*t);
	delete t;
	t = 0;
	return ti;
	}

TypeIterator<MDDType>
TypeFactory::createMDDIter()
	{
	RMDBGENTER(1, RMDebug::module_catalogmgr, "TypeFactory", "createMDDIter()");
	OIdSet theMDDTypes;
	OIdSet* tempList = 0;
	OIdSet::iterator i; 

	tempList = ObjectBroker::getAllObjects(OId::MDDTYPEOID);
	theMDDTypes = *tempList;
	delete tempList;

	tempList = ObjectBroker::getAllObjects(OId::MDDBASETYPEOID);
	while (!tempList->empty())
		{
		theMDDTypes.insert(*(tempList->begin()));
		tempList->erase(*(tempList->begin()));
		}
	delete tempList;

	tempList = ObjectBroker::getAllObjects(OId::MDDDIMTYPEOID);
	while (!tempList->empty())
		{
		theMDDTypes.insert(*(tempList->begin()));
		tempList->erase(*(tempList->begin()));
		}
	delete tempList;

	tempList = ObjectBroker::getAllObjects(OId::MDDDOMTYPEOID);
	while (!tempList->empty())
		{
		theMDDTypes.insert(*(tempList->begin()));
		tempList->erase(*(tempList->begin()));
		}
	delete tempList;

	RMDBGEXIT(1, RMDebug::module_catalogmgr, "TypeFactory", "createMDDIter()");
	return TypeIterator<MDDType>(theMDDTypes);
	}