summaryrefslogtreecommitdiffstats
path: root/relcatalogif
diff options
context:
space:
mode:
authorConstantin Jucovschi <cj@ubuntu.localdomain>2009-04-24 07:20:22 -0400
committerConstantin Jucovschi <cj@ubuntu.localdomain>2009-04-24 07:20:22 -0400
commit8f27e65bddd7d4b8515ce620fb485fdd78fcdf89 (patch)
treebd328a4dd4f92d32202241b5e3a7f36177792c5f /relcatalogif
downloadrasdaman-upstream-8f27e65bddd7d4b8515ce620fb485fdd78fcdf89.tar.gz
rasdaman-upstream-8f27e65bddd7d4b8515ce620fb485fdd78fcdf89.tar.xz
rasdaman-upstream-8f27e65bddd7d4b8515ce620fb485fdd78fcdf89.zip
Initial commitv8.0
Diffstat (limited to 'relcatalogif')
-rw-r--r--relcatalogif/Makefile.am69
-rw-r--r--relcatalogif/alltypes.hh38
-rw-r--r--relcatalogif/atomictype.C113
-rw-r--r--relcatalogif/atomictype.hh93
-rw-r--r--relcatalogif/basetype.C130
-rw-r--r--relcatalogif/basetype.hh161
-rw-r--r--relcatalogif/booltype.C157
-rw-r--r--relcatalogif/booltype.hh104
-rw-r--r--relcatalogif/chartype.C158
-rw-r--r--relcatalogif/chartype.hh106
-rw-r--r--relcatalogif/collectiontype.C98
-rw-r--r--relcatalogif/collectiontype.hh129
-rw-r--r--relcatalogif/complextype.hh131
-rw-r--r--relcatalogif/complextype.icc159
-rw-r--r--relcatalogif/compositetype.C104
-rw-r--r--relcatalogif/compositetype.hh99
-rw-r--r--relcatalogif/dbminterval.hh103
-rw-r--r--relcatalogif/dbminterval.lis0
-rw-r--r--relcatalogif/dbminterval.pgc381
-rw-r--r--relcatalogif/doubletype.C154
-rw-r--r--relcatalogif/doubletype.hh103
-rw-r--r--relcatalogif/floattype.C159
-rw-r--r--relcatalogif/floattype.hh95
-rw-r--r--relcatalogif/inlineminterval.cc139
-rw-r--r--relcatalogif/inlineminterval.hh73
-rw-r--r--relcatalogif/integraltype.hh89
-rw-r--r--relcatalogif/integraltype.icc53
-rw-r--r--relcatalogif/longtype.C147
-rw-r--r--relcatalogif/longtype.hh106
-rw-r--r--relcatalogif/mddbasetype.hh142
-rw-r--r--relcatalogif/mddbasetype.lis0
-rw-r--r--relcatalogif/mddbasetype.pgc125
-rw-r--r--relcatalogif/mddbasetypecommon.cc174
-rw-r--r--relcatalogif/mdddimensiontype.hh128
-rw-r--r--relcatalogif/mdddimensiontype.lis0
-rw-r--r--relcatalogif/mdddimensiontype.pgc148
-rw-r--r--relcatalogif/mdddimensiontypecommon.cc166
-rw-r--r--relcatalogif/mdddomaintype.hh137
-rw-r--r--relcatalogif/mdddomaintype.lis0
-rw-r--r--relcatalogif/mdddomaintype.pgc143
-rw-r--r--relcatalogif/mdddomaintypecommon.cc204
-rw-r--r--relcatalogif/mddtype.hh140
-rw-r--r--relcatalogif/mddtype.lis0
-rw-r--r--relcatalogif/mddtype.pgc128
-rw-r--r--relcatalogif/mddtypecommon.cc128
-rw-r--r--relcatalogif/octettype.C158
-rw-r--r--relcatalogif/octettype.hh103
-rw-r--r--relcatalogif/realtype.hh90
-rw-r--r--relcatalogif/realtype.icc52
-rw-r--r--relcatalogif/settype.hh82
-rw-r--r--relcatalogif/settype.lis0
-rw-r--r--relcatalogif/settype.pgc140
-rw-r--r--relcatalogif/settypecommon.cc89
-rw-r--r--relcatalogif/shorttype.C153
-rw-r--r--relcatalogif/shorttype.hh104
-rw-r--r--relcatalogif/structtype.hh173
-rw-r--r--relcatalogif/structtype.icc54
-rw-r--r--relcatalogif/structtype.lis0
-rw-r--r--relcatalogif/structtype.pgc214
-rw-r--r--relcatalogif/structtypecommon.cc511
-rw-r--r--relcatalogif/type.C138
-rw-r--r--relcatalogif/type.hh137
-rw-r--r--relcatalogif/typeiterator.C0
-rw-r--r--relcatalogif/typeiterator.hh30
-rw-r--r--relcatalogif/uintegraltype.hh90
-rw-r--r--relcatalogif/uintegraltype.icc51
-rw-r--r--relcatalogif/ulongtype.C149
-rw-r--r--relcatalogif/ulongtype.hh101
-rw-r--r--relcatalogif/ushorttype.C155
-rw-r--r--relcatalogif/ushorttype.hh100
70 files changed, 8088 insertions, 0 deletions
diff --git a/relcatalogif/Makefile.am b/relcatalogif/Makefile.am
new file mode 100644
index 0000000..19ebca8
--- /dev/null
+++ b/relcatalogif/Makefile.am
@@ -0,0 +1,69 @@
+# -*-Makefile-*- (for Emacs)
+# 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>.
+#
+# MAKEFILE FOR:
+# relcatalogif
+#
+# COMMENTS:
+#
+##################################################################
+
+#
+# This Makefile only works with GNU Make!
+#
+
+######################### Definitions ############################
+
+AM_CXXFLAGS=@BASEDBCXXFLAGS@
+AM_LDFLAGS=@BASEDBLDFLAGS@
+
+.SUFFIXES= .@EMBEDDEDSQLEXT@ .@EMBEDDEDSQLOUT@
+.@EMBEDDEDSQLEXT@.@EMBEDDEDSQLOUT@:
+ $(EMBEDDEDSQLPRECOMPILER) $@ $<
+
+noinst_LIBRARIES=librelcatalogif.a
+librelcatalogif_a_SOURCES= type.C type.hh basetype.C basetype.hh atomictype.C ulongtype.C ulongtype.hh ushorttype.C ushorttype.hh \
+ booltype.C booltype.hh compositetype.C compositetype.hh structtypecommon.cc structtype.hh structtype.icc \
+ longtype.C longtype.hh shorttype.C shorttype.hh octettype.C octettype.hh doubletype.C doubletype.hh\
+ floattype.C floattype.hh chartype.C chartype.hh collectiontype.C collectiontype.hh settypecommon.cc settype.hh\
+ mddtypecommon.cc mddtype.hh mddbasetypecommon.cc mddbasetype.hh mdddomaintypecommon.cc mdddomaintype.hh\
+ mdddimensiontypecommon.cc mdddimensiontype.hh dbminterval.hh inlineminterval.cc inlineminterval.hh \
+ typeiterator.hh atomictype.hh uintegraltype.hh uintegraltype.icc integraltype.hh \
+ integraltype.icc realtype.hh realtype.icc alltypes.hh complextype.hh complextype.icc
+EXTRA_librelcatalogif_a_SOURCES= settype.pgc mddtype.pgc mddbasetype.pgc mdddomaintype.pgc mdddimensiontype.pgc structtype.pgc dbminterval.pgc
+librelcatalogif_a_LIBADD= settype.$(OBJEXT) mddtype.$(OBJEXT) mddbasetype.$(OBJEXT) mdddimensiontype.$(OBJEXT) \
+ structtype.$(OBJEXT) dbminterval.$(OBJEXT) mdddomaintype.$(OBJEXT)
+librelcatalogif_a_DEPENDENCIES= settype.$(OBJEXT) mddtype.$(OBJEXT) mddbasetype.$(OBJEXT) mdddimensiontype.$(OBJEXT) \
+ structtype.$(OBJEXT) dbminterval.$(OBJEXT) mdddomaintype.$(OBJEXT)
+
+BUILT_SOURCES= settype.@EMBEDDEDSQLOUT@ mddtype.@EMBEDDEDSQLOUT@ mddbasetype.@EMBEDDEDSQLOUT@ \
+ mdddimensiontype.@EMBEDDEDSQLOUT@ structtype.@EMBEDDEDSQLOUT@ dbminterval.@EMBEDDEDSQLOUT@ \
+ mdddomaintype.@EMBEDDEDSQLOUT@
+
+
+CLEANFILES=settype.@EMBEDDEDSQLOUT@ mddtype.@EMBEDDEDSQLOUT@ mddbasetype.@EMBEDDEDSQLOUT@ \
+ mdddimensiontype.@EMBEDDEDSQLOUT@ structtype.@EMBEDDEDSQLOUT@ dbminterval.@EMBEDDEDSQLOUT@ \
+ mdddomaintype.@EMBEDDEDSQLOUT@ \
+ client.bm client.dbg client.log ir.out core
+
+
+
diff --git a/relcatalogif/alltypes.hh b/relcatalogif/alltypes.hh
new file mode 100644
index 0000000..6ecadff
--- /dev/null
+++ b/relcatalogif/alltypes.hh
@@ -0,0 +1,38 @@
+/*
+* 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>.
+*/
+#include "ulongtype.hh"
+#include "longtype.hh"
+#include "chartype.hh"
+#include "booltype.hh"
+#include "octettype.hh"
+#include "ushorttype.hh"
+#include "shorttype.hh"
+#include "floattype.hh"
+#include "doubletype.hh"
+#include "structtype.hh"
+#include "settype.hh"
+#include "mddtype.hh"
+#include "mddbasetype.hh"
+#include "mdddomaintype.hh"
+#include "mdddimensiontype.hh"
+#include "complextype.hh"
diff --git a/relcatalogif/atomictype.C b/relcatalogif/atomictype.C
new file mode 100644
index 0000000..a7b4b65
--- /dev/null
+++ b/relcatalogif/atomictype.C
@@ -0,0 +1,113 @@
+/*
+* 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>.
+*/
+/*************************************************************
+ *
+ *
+ * PURPOSE:
+ * uses ODMG-conformant O2 classes
+ *
+ *
+ * COMMENTS:
+ * none
+ *
+ ************************************************************/
+
+static const char rcsid[] = "@(#)catalogif,AtomicType: $Id: atomictype.C,v 1.4 2001/06/20 08:06:37 hoefner Exp $";
+
+#include "atomictype.hh"
+#include "reladminif/externs.h"
+
+/*************************************************************
+ * Method name...: AtomicType();
+ *
+ * Arguments.....: none
+ * Return value..: none
+ * Description...: initializes member variables for an
+ * AtomicType.
+ ************************************************************/
+
+AtomicType::AtomicType(unsigned int newSize)
+ : BaseType("unnamed atomictype"),
+ size(newSize)
+ {
+ objecttype = OId::ATOMICTYPEOID;
+ _isPersistent = 1;
+ _isInDatabase = 1;
+ _isModified = 0;
+ }
+
+AtomicType::AtomicType(const char* name, unsigned int newSize)
+ : BaseType(name),
+ size(newSize)
+ {
+ objecttype = OId::ATOMICTYPEOID;
+ _isPersistent = 1;
+ _isInDatabase = 1;
+ _isModified = 0;
+ }
+
+AtomicType::AtomicType(const AtomicType& old)
+ : BaseType(old),
+ size(old.size)
+ {
+ objecttype = OId::ATOMICTYPEOID;
+ _isPersistent = 1;
+ _isInDatabase = 1;
+ _isModified = 0;
+ }
+
+AtomicType::AtomicType(const OId& id) throw (r_Error)
+ : BaseType(id)
+ {
+ objecttype = OId::ATOMICTYPEOID;
+ _isPersistent = 1;
+ _isInDatabase = 1;
+ _isModified = 0;
+ }
+
+AtomicType::~AtomicType()
+ {
+ }
+
+AtomicType&
+AtomicType::operator=(const AtomicType& old)
+ {
+ BaseType::operator=(old);
+ size = old.size;
+ return *this;
+ }
+
+/*************************************************************
+ * Method name...: unsigned int getSize() const
+ *
+ * Arguments.....: none
+ * Return value..: size in d_Octets
+ * Description...: returns size of AtomicType in chars
+ ************************************************************/
+
+unsigned int
+AtomicType::getSize() const
+{
+ return size;
+}
+
diff --git a/relcatalogif/atomictype.hh b/relcatalogif/atomictype.hh
new file mode 100644
index 0000000..3a7523b
--- /dev/null
+++ b/relcatalogif/atomictype.hh
@@ -0,0 +1,93 @@
+/*
+* 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>.
+*/
+// -*-C++-*- (for Emacs)
+
+/*************************************************************
+ *
+ *
+ * PURPOSE:
+ * The AtomicType class is the superclass for all for
+ * atomic types (e.g. Octet, ULong) describing the type of a
+ * cell
+ *
+ *
+ * COMMENTS:
+ *
+ ************************************************************/
+
+#ifndef _ATOMICTYPE_HH_
+#define _ATOMICTYPE_HH_
+
+#include <iostream>
+#include "basetype.hh"
+
+//@ManMemo: Module: {\bf relcatalogif}.
+
+/*@Doc:
+AtomicType is the abstract base class for all non-structured
+\Ref{BaseType} subclasses, i.e. base types like \Ref{ULongType} or
+\Ref{BoolType}.
+*/
+
+class AtomicType : public BaseType
+ {
+ public:
+ virtual unsigned int getSize() const;
+ /*@Doc:
+ get size of cells of this base type.
+ */
+
+ AtomicType(unsigned int newSize);
+ /*@Doc:
+ constructor.
+ */
+
+ AtomicType(const AtomicType& old);
+ /*@Doc:
+ copy constructor.
+ */
+
+ AtomicType(const OId& id) throw (r_Error);
+ /*@Doc:
+ */
+
+ AtomicType& operator=(const AtomicType& old);
+ /*@Doc:
+ */
+
+ virtual ~AtomicType();
+ /*@Doc:
+ */
+
+ protected:
+ unsigned int size;
+ /*@Doc:
+ size of one cell of this base type in number of chars.
+ */
+
+ AtomicType(const char* name, unsigned int newSize);
+ /*@Doc:
+ */
+ };
+
+#endif
diff --git a/relcatalogif/basetype.C b/relcatalogif/basetype.C
new file mode 100644
index 0000000..a01f208
--- /dev/null
+++ b/relcatalogif/basetype.C
@@ -0,0 +1,130 @@
+/*
+* 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>.
+*/
+/*************************************************************
+ *
+ *
+ * PURPOSE:
+ * uses ODMG-conformant O2 classes
+ *
+ *
+ * COMMENTS:
+ * none
+ *
+ ************************************************************/
+
+static const char rcsid[] = "@(#)catalogif,BaseType: $Id: basetype.C,v 1.11 2001/06/20 08:06:37 hoefner Exp $";
+
+#include "basetype.hh"
+#include "raslib/rmdebug.hh"
+#include "reladminif/externs.h"
+
+BaseType::BaseType(const char* name)
+ : Type(name)
+ {
+ RMDBGONCE(7, RMDebug::module_catalogif, "BaseType", "BaseType(" << getName() << ")");
+ }
+
+/*************************************************************
+ * Method name...: BaseType()
+ *
+ * Arguments.....: none
+ * Return value..: none
+ * Description...: constructor
+ ************************************************************/
+
+BaseType::BaseType()
+ : Type("unnamed basetype")
+ {
+ RMDBGONCE(7, RMDebug::module_catalogif, "BaseType", "BaseType()");
+ }
+
+BaseType::BaseType(const OId& id) throw (r_Error)
+ : Type(id)
+ {
+ RMDBGONCE(7, RMDebug::module_catalogif, "BaseType", "BaseType(" << myOId << ")");
+ }
+
+BaseType::BaseType(const BaseType& old)
+ : Type(old)
+ {
+ }
+
+/*************************************************************
+ * Method name...: ~BaseType()
+ *
+ * Arguments.....: none
+ * Return value..: none
+ * Description...: virtual destructor
+ ************************************************************/
+
+BaseType::~BaseType()
+ {
+ }
+
+BaseType&
+BaseType::operator=(const BaseType& old)
+ {
+ Type::operator=(old);
+ return *this;
+ }
+
+/*************************************************************
+ * Method name...: UnaryOp* getUnaryOp( Ops::OpType optype )
+ *
+ * Arguments.....:
+ * optype: operation to return
+ * Return value..:
+ * pointer to ther UnaryOp requested
+ * Description...: return requested UnaryOp for ULongType
+ ************************************************************/
+
+UnaryOp*
+BaseType::getUnaryOp( Ops::OpType op, const BaseType* optype ) const
+{
+ return Ops::getUnaryOp(op, (const BaseType*)this, optype);
+}
+
+BinaryOp*
+BaseType::getBinaryOp( Ops::OpType op, const BaseType* op1type,
+ const BaseType* op2type ) const
+{
+ return Ops::getBinaryOp(op, (const BaseType*)this, op1type, op2type);
+}
+
+
+CondenseOp*
+BaseType::getCondenseOp( Ops::OpType op ) const
+{
+ return Ops::getCondenseOp(op, (const BaseType*)this);
+}
+
+
+int
+BaseType::compatibleWith(const Type* aType) const
+ {
+ RMDBGENTER(7, RMDebug::module_catalogif, "BaseType", "compatibleWith(" << aType->getName() << ") " << getName());
+ int retval = (myType == aType->getType());
+ RMDBGEXIT(7, RMDebug::module_catalogif, "BaseType", "compatibleWith(" << aType->getName() << ") " << getName() << " " << retval);
+ return retval;
+ }
+
diff --git a/relcatalogif/basetype.hh b/relcatalogif/basetype.hh
new file mode 100644
index 0000000..f01bd60
--- /dev/null
+++ b/relcatalogif/basetype.hh
@@ -0,0 +1,161 @@
+/*
+* 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>.
+*/
+// -*-C++-*- (for Emacs)
+
+/*************************************************************
+ *
+ *
+ * PURPOSE:
+ * The BaseType class is the superclass for all classes
+ * describing the type of a cell
+ *
+ *
+ * COMMENTS:
+ *
+ ************************************************************/
+
+#ifndef _BASETYPE_HH_
+#define _BASETYPE_HH_
+
+#include <iostream>
+#include "catalogmgr/ops.hh"
+#include "type.hh"
+#include "raslib/odmgtypes.hh"
+
+//@ManMemo: Module: {\bf relcatalogif}.
+
+/*@Doc:
+BaseType is the abstract base class for all types usable as basetypes
+for an MDD. At the moment, only atomic types are supported. Later
+structured types will also be supported.
+
+Common to each basetype is the ability to get size information,to
+print a cell and to provide means to carry out operations on cells of
+this type. This functionality is defined as pure virtual functions
+here.
+
+{\bf Interdependencies}
+
+Each \Ref{Tile} has a pointer to its BaseType. Pointers to BaseType
+are also used in subclasses of \Ref{MDDObject}.
+*/
+
+class BaseType : public Type
+ {
+ public:
+ virtual unsigned int getSize() const = 0;
+ /*@Doc:
+ returns the size of one cell of the type in chars.
+ */
+
+ virtual r_ULong* convertToCULong(const char* cell, r_ULong* value) const = 0;
+
+ /*@Doc:
+ returns value of the cell as a C #unsigned long#.
+ */
+
+ virtual char* makeFromCULong(char* cell, const r_ULong* value) const = 0;
+ /*@Doc:
+ returns C #unsigned long# in cell #cell#.
+ */
+
+ virtual r_Long* convertToCLong(const char* cell, r_Long* value) const = 0;
+ /*@Doc:
+ returns value of the cell as a C #long#.
+ */
+
+ virtual char* makeFromCLong(char* cell, const r_Long* value) const = 0;
+ /*@Doc:
+ returns C #long# in cell #cell#.
+ */
+
+ virtual double* convertToCDouble(const char* cell, double* value) const = 0;
+ /*@Doc:
+ returns value of the cell as a C #double#.
+ */
+
+ virtual char* makeFromCDouble(char* cell, const double* value) const = 0;
+ /*@Doc:
+ returns C #double# in cell #cell#.
+ */
+
+ virtual void printCell(ostream& stream, const char* cell) const = 0;
+ /*@Doc:
+ print contents of a cell to stream.
+ */
+
+ //@Man: methods for getting functions (used by \Ref{Tile})
+ //@{
+ /// get function object for condense operation.
+ virtual CondenseOp* getCondenseOp( Ops::OpType op ) const;
+ /*@Doc:
+ \Ref{CondenseOp} carrying out the operation op on a cell of this
+ type. The type of the result depends on the operation carried out,
+ but is usually of type self. See \Ref{Ops} for details.
+ */
+
+ /// get function object for unary operation.
+ virtual UnaryOp* getUnaryOp( Ops::OpType op, const BaseType* optype ) const;
+ /*@Doc:
+ Returns a pointer to a function object of a subclass of class
+ \Ref{UnaryOp} carrying out the operation {\tt op} on a cell of
+ type {\tt optype}. The result type has the type self. See
+ \Ref{Ops} for details.
+ */
+
+ /// get function object for binary operation.
+ virtual BinaryOp* getBinaryOp( Ops::OpType op, const BaseType* op1type, const BaseType* op2type) const;
+ /*@Doc:
+ Returns a pointer to a function object of a subclass of class
+ \Ref{BinaryOp} carrying out the operation {\tt op} on two cells of
+ type {\tt op1type} respective {\tt op2type}. The result type has
+ the type self. See \Ref{Ops} for details.
+ */
+ //@}
+
+ BaseType();
+ /*@Doc:
+ default constructor, cannot be used.
+ */
+
+ BaseType(const OId& id) throw (r_Error);
+
+ BaseType(const BaseType& old);
+
+ BaseType& operator=(const BaseType& old);
+
+ virtual ~BaseType();
+ /*@Doc:
+ virtual destructor.
+ */
+
+ virtual int compatibleWith(const Type* aType) const;
+ /*@Doc:
+ returns true if my TypeEnum == aType->getType()
+ */
+
+ protected:
+ BaseType(const char* name);
+ };
+
+#endif
diff --git a/relcatalogif/booltype.C b/relcatalogif/booltype.C
new file mode 100644
index 0000000..b6025b4
--- /dev/null
+++ b/relcatalogif/booltype.C
@@ -0,0 +1,157 @@
+/*
+* 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>.
+*/
+/*************************************************************
+ *
+ *
+ * PURPOSE:
+ * uses ODMG-conformant O2 classes
+ *
+ *
+ * COMMENTS:
+ * none
+ *
+ ************************************************************/
+
+static const char rcsid[] = "@(#)catalogif,BoolType: $Header: /home/rasdev/CVS-repository/rasdaman/relcatalogif/booltype.C,v 1.8 2003/12/27 23:23:04 rasdev Exp $";
+
+#include "booltype.hh"
+#include <string.h>
+
+/*************************************************************
+ * Method name...: BoolType();
+ *
+ * Arguments.....: none
+ * Return value..: none
+ * Description...: initializes member variables for an
+ * BoolType.
+ ************************************************************/
+
+BoolType::BoolType(const OId& id) throw (r_Error)
+ : UIntegralType(id)
+ {
+ readFromDb();
+ }
+
+BoolType::BoolType()
+ : UIntegralType(BoolType::Name, 1)
+ {
+ myType = BOOLTYPE;
+ myOId = OId(BOOLTYPE, OId::ATOMICTYPEOID);
+ }
+
+/*************************************************************
+ * Method name...: BoolType(const BoolType& old);
+ *
+ * Arguments.....: none
+ * Return value..: none
+ * Description...: copy constructor
+ ************************************************************/
+
+BoolType::BoolType(const BoolType& old)
+ : UIntegralType(old)
+ {
+ }
+
+/*************************************************************
+ * Method name...: operator=(const BoolType&);
+ *
+ * Arguments.....: none
+ * Return value..: none
+ * Description...: copy constructor
+ ************************************************************/
+
+BoolType&
+BoolType::operator=(const BoolType& old)
+ {
+ // Gracefully handle self assignment
+ if (this == &old)
+ return *this;
+ AtomicType::operator=(old);
+ return *this;
+ }
+
+/*************************************************************
+ * Method name...: ~BoolType();
+ *
+ * Arguments.....: none
+ * Return value..: none
+ * Description...: virtual destructor
+ ************************************************************/
+
+BoolType::~BoolType()
+ {
+ }
+
+/*************************************************************
+ * Method name...: void printCell( ostream& stream,
+ * const char* cell )
+ *
+ * Arguments.....:
+ * stream: stream to print on
+ * cell: pointer to cell to print
+ * Return value..: none
+ * Description...: prints a cell cell in hex on stream
+ * followed by a space.
+ * Assumes that Bool is stored MSB..LSB
+ * on HP.
+ ************************************************************/
+
+void
+BoolType::printCell( ostream& stream, const char* cell ) const
+{
+ if(*cell == 0)
+ stream << "FALSE ";
+ else
+ stream << "TRUE ";
+}
+
+r_ULong*
+BoolType::convertToCULong(const char* cell, r_ULong* value) const
+{
+ // !!!! HP specific, assumes 4 Byte long and MSB..LSB
+ // byte order
+ //*value = *(unsigned char*)cell;
+
+ *value = *(unsigned char*)cell ? 1: 0;
+ return value;
+}
+
+
+char*
+BoolType::makeFromCULong(char* cell, const r_ULong* value) const
+{
+ // !!!! HP specific, assumes 4 Byte long and MSB..LSB
+ // byte order
+ *(unsigned char*)(cell) = (unsigned char)(*value);
+ return cell;
+}
+
+void
+BoolType::readFromDb() throw (r_Error)
+ {
+ setName(BoolType::Name);
+ size = 1;
+ myType = BOOLTYPE;
+ myOId = OId(BOOLTYPE, OId::ATOMICTYPEOID);
+ }
+
diff --git a/relcatalogif/booltype.hh b/relcatalogif/booltype.hh
new file mode 100644
index 0000000..9810055
--- /dev/null
+++ b/relcatalogif/booltype.hh
@@ -0,0 +1,104 @@
+/*
+* 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>.
+*/
+// -*-C++-*- (for Emacs)
+
+/*************************************************************
+ *
+ *
+ * PURPOSE:
+ * The ULongType class is the superclass for all classes
+ * describing the type of a cell
+ *
+ *
+ * COMMENTS:
+ *
+ ************************************************************/
+
+#ifndef _BOOLTYPE_HH_
+#define _BOOLTYPE_HH_
+
+#include <iostream>
+#include "uintegraltype.hh"
+#include "catalogmgr/ops.hh"
+
+class OId;
+
+//@ManMemo: Module: {\bf relcatalogif}.
+
+/*@Doc:
+
+BoolType is the base type used for boolean cell values (e.g. result
+of comparison operations, see \Ref{Ops}). The value of a Bool is
+stored in one char. BoolType is a persistence capable class.
+*/
+
+class BoolType : public UIntegralType
+ {
+ public:
+ BoolType(const OId& id) throw (r_Error);
+
+ BoolType();
+ /*@Doc:
+ default constructor, no initialization needed for BoolType.
+ */
+
+ BoolType(const BoolType& old);
+ /*@Doc:
+ copy constructor.
+ */
+
+ BoolType& operator=(const BoolType& old);
+ /*@Doc:
+ assignment operator.
+ */
+
+ virtual ~BoolType();
+ /*@Doc:
+ virtual destructor.
+ */
+
+ virtual void printCell(ostream& stream, const char* cell) const;
+ /*@Doc:
+ */
+
+ virtual r_ULong* convertToCULong(const char* cell, r_ULong* value) const;
+ /*@Doc:
+ */
+
+ virtual char* makeFromCULong(char* cell, const r_ULong* value) const;
+ /*@Doc:
+ */
+
+ static const char* Name;
+
+ protected:
+
+ virtual void readFromDb() throw (r_Error);
+ /*@Doc:
+ initializes the attributes of this type.
+ there is no database activity. this is hard coded.
+ */
+
+ };
+
+#endif
diff --git a/relcatalogif/chartype.C b/relcatalogif/chartype.C
new file mode 100644
index 0000000..3ac3f6a
--- /dev/null
+++ b/relcatalogif/chartype.C
@@ -0,0 +1,158 @@
+/*
+* 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>.
+*/
+/*************************************************************
+ *
+ *
+ * PURPOSE:
+ * uses ODMG-conformant O2 classes
+ *
+ *
+ * COMMENTS:
+ * none
+ *
+ ************************************************************/
+
+static const char rcsid[] = "@(#)catalogif,CharType: $Header: /home/rasdev/CVS-repository/rasdaman/relcatalogif/chartype.C,v 1.10 2003/12/27 23:23:04 rasdev Exp $";
+
+#include "chartype.hh"
+#include <iomanip>
+#include <string.h>
+#include <limits.h>
+
+/*************************************************************
+ * Method name...: CharType();
+ *
+ * Arguments.....: none
+ * Return value..: none
+ * Description...: initializes member variables for an
+ * CharType.
+ ************************************************************/
+
+CharType::CharType()
+ : UIntegralType(CharType::Name, 1)
+ {
+ myType = CHAR;
+ myOId = OId(CHAR, OId::ATOMICTYPEOID);
+ }
+
+/*************************************************************
+ * Method name...: CharType(const CharType& old);
+ *
+ * Arguments.....: none
+ * Return value..: none
+ * Description...: copy constructor
+ ************************************************************/
+
+CharType::CharType(const CharType& old)
+ : UIntegralType(CharType::Name, old.size)
+ {
+ }
+
+CharType::CharType(const OId& id) throw (r_Error)
+ : UIntegralType(OId(CHAR, OId::ATOMICTYPEOID))
+ {
+ readFromDb();
+ }
+
+/*************************************************************
+ * Method name...: operator=(const CharType&);
+ *
+ * Arguments.....: none
+ * Return value..: none
+ * Description...: copy constructor
+ ************************************************************/
+
+CharType&
+CharType::operator=(const CharType& old)
+ {
+ // Gracefully handle self assignment
+ if (this == &old)
+ return *this;
+ AtomicType::operator=(old);
+ return *this;
+ }
+
+void
+CharType::readFromDb() throw (r_Error)
+ {
+ setName(CharType::Name);
+ myType = CHAR;
+ myOId = OId(CHAR, OId::ATOMICTYPEOID);
+ size = 1;
+ }
+
+/*************************************************************
+ * Method name...: ~CharType();
+ *
+ * Arguments.....: none
+ * Return value..: none
+ * Description...: virtual destructor
+ ************************************************************/
+
+CharType::~CharType()
+ {
+ }
+
+/*************************************************************
+ * Method name...: void printCell( ostream& stream,
+ * const char* cell )
+ *
+ * Arguments.....:
+ * stream: stream to print on
+ * cell: pointer to cell to print
+ * Return value..: none
+ * Description...: prints a cell cell in hex on stream
+ * followed by a space.
+ * Assumes that Char is stored MSB..LSB
+ * on HP.
+ ************************************************************/
+
+void
+CharType::printCell( ostream& stream, const char* cell ) const
+{
+ // !!!! HP specific, assumes 1 Byte char
+ stream << std::setw(4) << (r_Long)(*(unsigned char*)cell);
+}
+
+r_ULong*
+CharType::convertToCULong(const char* cell, r_ULong* value) const
+{
+ // !!!! HP specific, assumes 4 Byte long and MSB..LSB
+ // byte order
+ *value = *(unsigned char*)cell;
+ return value;
+}
+
+
+char*
+CharType::makeFromCULong(char* cell, const r_ULong* value) const
+ {
+ r_ULong myLong = *value;
+ //restricting long to value range of short
+ myLong = myLong > UCHAR_MAX ? UCHAR_MAX : myLong;
+ myLong = myLong < 0 ? 0 : myLong;
+ // !!!! HP specific, assumes 4 Byte long and MSB..LSB
+ // byte order
+ *(unsigned char*)(cell)=(unsigned char)myLong;
+ return cell;
+ }
diff --git a/relcatalogif/chartype.hh b/relcatalogif/chartype.hh
new file mode 100644
index 0000000..2a8fd8c
--- /dev/null
+++ b/relcatalogif/chartype.hh
@@ -0,0 +1,106 @@
+/*
+* 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>.
+*/
+// -*-C++-*- (for Emacs)
+
+/*************************************************************
+ *
+ *
+ * PURPOSE:
+ * The CharType class represents unsigned char.
+ *
+ *
+ * COMMENTS:
+ *
+ ************************************************************/
+
+#ifndef _CHARTYPE_HH_
+#define _CHARTYPE_HH_
+
+#include <iostream>
+#include "raslib/odmgtypes.hh"
+#include "uintegraltype.hh"
+#include "catalogmgr/ops.hh"
+
+class OId;
+
+//@ManMemo: Module: {\bf relcatalogif}.
+
+/*@Doc:
+
+CharType is the base type used for unsigned char cell values (e.g.
+result of comparison operations, see \Ref{Ops}). The value of a Char
+is stored in one char. CharType is a persistence capable class.
+*/
+
+class CharType : public UIntegralType
+ {
+ public:
+ CharType();
+ /*@Doc:
+ default constructor, no initialization needed for CharType.
+ */
+
+ CharType(const OId& id) throw (r_Error);
+ /*@Doc:
+ */
+
+ CharType(const CharType& old);
+ /*@Doc:
+ copy constructor.
+ */
+
+ CharType& operator=(const CharType& old);
+ /*@Doc:
+ assignment operator.
+ */
+
+ virtual ~CharType();
+ /*@Doc:
+ virtual destructor.
+ */
+
+ virtual void printCell(ostream& stream, const char* cell) const;
+ /*@Doc:
+ */
+
+ virtual r_ULong* convertToCULong(const char* cell, r_ULong* value) const;
+ /*@Doc:
+ */
+
+ virtual char* makeFromCULong(char* cell, const r_ULong* value) const;
+ /*@Doc:
+ */
+
+ static const char* Name;
+
+ protected:
+
+ virtual void readFromDb() throw (r_Error);
+ /*@Doc:
+ initializes the attributes of this type.
+ there is no database activity. this is hard coded.
+ */
+
+ };
+
+#endif
diff --git a/relcatalogif/collectiontype.C b/relcatalogif/collectiontype.C
new file mode 100644
index 0000000..26e9f1d
--- /dev/null
+++ b/relcatalogif/collectiontype.C
@@ -0,0 +1,98 @@
+/*
+* 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>.
+*/
+#include "collectiontype.hh"
+#include "mddtype.hh"
+
+r_Bytes
+CollectionType::getMemorySize() const
+ {
+ return DBNamedObject::getMemorySize() + myMDDType->getMemorySize() + sizeof(MDDType*);
+ }
+
+CollectionType::CollectionType(const MDDType* newMDDType)
+ : Type("unnamed collectiontype")
+ {
+ myMDDType = newMDDType;
+ }
+
+CollectionType::CollectionType()
+ : Type("unnamed collectiontype")
+ {
+ myMDDType = 0;
+ }
+
+CollectionType::CollectionType(const char* name)
+ : Type(name)
+ {
+ myMDDType = 0;
+ }
+
+
+CollectionType::CollectionType(const char* name, const MDDType* newMDDType)
+ : Type(name)
+ {
+ myMDDType = newMDDType;
+ }
+
+CollectionType::CollectionType(const OId& id) throw (r_Error)
+ : Type(id)
+ {
+ }
+
+CollectionType::CollectionType(const CollectionType& old)
+ : Type(old)
+ {
+ myMDDType = old.myMDDType;
+ }
+
+CollectionType&
+CollectionType::operator=(const CollectionType& old)
+ {
+ Type::operator=(old);
+ myMDDType = old.myMDDType;
+ return *this;
+ }
+
+CollectionType::~CollectionType()
+ {
+ }
+
+const MDDType*
+CollectionType::getMDDType() const
+ {
+ return myMDDType;
+ }
+
+void
+CollectionType::print_status( ostream& s ) const
+{
+ s << "d_" << getName() << "<";
+ myMDDType->print_status(s);
+ s << " >";
+}
+
+int
+CollectionType::compatibleWith(const Type* aType) const
+{
+ return myMDDType->compatibleWith(aType);
+}
diff --git a/relcatalogif/collectiontype.hh b/relcatalogif/collectiontype.hh
new file mode 100644
index 0000000..591d715
--- /dev/null
+++ b/relcatalogif/collectiontype.hh
@@ -0,0 +1,129 @@
+/*
+* 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>.
+*/
+// -*-C++-*- (for Emacs)
+
+/*************************************************************
+ *
+ *
+ * PURPOSE:
+ * The CollectionType class is the superclass for the class
+ * SetType.
+ *
+ *
+ * COMMENTS:
+ *
+ ************************************************************/
+
+#ifndef _COLLECTIONTYPE_HH_
+#define _COLLECTIONTYPE_HH_
+
+class CollectionType;
+
+#include <iostream>
+#include "catalogmgr/ops.hh"
+#include "type.hh"
+#include "reladminif/externs.h"
+
+class MDDType;
+
+//@ManMemo: Module: {\bf relcatalogif}.
+
+/*@Doc:
+ CollectionType is the base class for classes that deal with
+ collections of MDDs (the only subclass at the moment is SetType).
+*/
+
+class CollectionType : public Type
+ {
+ public:
+ const MDDType* getMDDType() const;
+ /*@Doc:
+ returns MDDType of collection.
+ */
+ /*
+ MDDType* getMDDType() const;
+ */
+
+
+ void print_status( ostream& s ) const;
+ /*@Doc:
+ writes the state of the object to the specified stream:
+ d_MYNAME <MYMDDTYPE->printStatus >
+ */
+
+ CollectionType(const MDDType* newMDDType);
+ /*@Doc:
+ constructor receiving pointer to an MDDType (or subclass).
+ */
+
+ CollectionType();
+ /*@Doc:
+ default constructor, cannot be used.
+ */
+
+ CollectionType(const OId& id) throw (r_Error);
+ /*@Doc:
+ */
+
+ CollectionType(const CollectionType& old);
+ /*@Doc:
+ */
+
+ CollectionType& operator=(const CollectionType& old);
+ /*@Doc:
+ */
+
+ virtual ~CollectionType();
+ /*@Doc:
+ virtual destructor.
+ */
+
+ virtual int compatibleWith(const Type* aType) const;
+ /*@Doc:
+ overloaded from Type.
+ returns true if myMDDType is compatible with the type.
+ */
+
+ virtual r_Bytes getMemorySize() const;
+ /*@Doc:
+ returns DBNamedObject::getMemorySize() +
+ myMDDType->getMemorySize() + sizeof(MDDType*);
+ */
+
+ protected:
+ const MDDType* myMDDType;
+ /*@Doc:
+ persistent pointer to MDDType of collection.
+ */
+
+ CollectionType(const char* name);
+ /*@Doc:
+ */
+
+ CollectionType(const char* name,const MDDType* newMDDType);
+ /*@Doc:
+ */
+ };
+
+#endif
+
diff --git a/relcatalogif/complextype.hh b/relcatalogif/complextype.hh
new file mode 100644
index 0000000..9d18e32
--- /dev/null
+++ b/relcatalogif/complextype.hh
@@ -0,0 +1,131 @@
+/*
+* 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>.
+*/
+// -*-C++-*- (for Emacs)
+
+/*************************************************************
+ *
+ *
+ * PURPOSE:
+ *
+ *
+ *
+ *
+ * COMMENTS:
+ *
+ ************************************************************/
+
+#ifndef _COMPLEXTYPE_HH_
+#define _COMPLEXTYPE_HH_
+
+#include <iostream>
+#include <values.h>
+#include "realtype.hh"
+#include "catalogmgr/ops.hh"
+
+class OId;
+
+
+
+class GenericComplexType : public AtomicType {
+
+public:
+ GenericComplexType(const char *name, unsigned int size): AtomicType(name, size) {}
+ GenericComplexType(const OId& id) throw (r_Error): AtomicType(id) {}
+ virtual ~GenericComplexType() {}
+ virtual unsigned int getReOffset() const = 0;
+ virtual unsigned int getImOffset() const = 0;
+
+protected:
+ virtual void readFromDb() throw (r_Error) = 0;
+};
+
+
+class ComplexType1 : public GenericComplexType {
+
+public:
+ ComplexType1();
+ ComplexType1(const OId& id) throw (r_Error);
+ ComplexType1(const ComplexType1& old);
+ ComplexType1& operator=(const ComplexType1& old);
+ virtual ~ComplexType1();
+ virtual void printCell(ostream& stream, const char* cell) const;
+ unsigned int getReOffset() const;
+ unsigned int getImOffset() const;
+ virtual const char* getTypeName() const;
+ static const char* Name;
+
+
+protected:
+ virtual void readFromDb() throw (r_Error);
+
+private:
+ unsigned int reOffset, imOffset;
+
+// static const char* complexTypeName;
+
+ r_ULong* convertToCULong(const char*, r_ULong*) const;
+ char* makeFromCULong(char*, const r_ULong*) const;
+ r_Long* convertToCLong(const char*, r_Long*) const;
+ char* makeFromCLong(char*, const r_Long*) const;
+ double* convertToCDouble(const char* cell, double* value) const;
+ char* makeFromCDouble(char* cell, const double* value) const;
+
+};
+
+class ComplexType2 : public GenericComplexType {
+
+public:
+ ComplexType2();
+ ComplexType2(const OId& id) throw (r_Error);
+ ComplexType2(const ComplexType2& old);
+ ComplexType2& operator=(const ComplexType2& old);
+ virtual ~ComplexType2();
+ virtual void printCell(ostream& stream, const char* cell) const;
+ unsigned int getReOffset() const;
+ unsigned int getImOffset() const;
+ virtual const char* getTypeName() const;
+ static const char* Name;
+
+protected:
+ virtual void readFromDb() throw (r_Error);
+
+private:
+ unsigned int reOffset, imOffset;
+
+// static const char* complexTypeName;
+
+ r_ULong* convertToCULong(const char*, r_ULong*) const;
+ char* makeFromCULong(char*, const r_ULong*) const;
+ r_Long* convertToCLong(const char*, r_Long*) const;
+ char* makeFromCLong(char*, const r_Long*) const;
+ double* convertToCDouble(const char* cell, double* value) const;
+ char* makeFromCDouble(char* cell, const double* value) const;
+
+};
+
+
+#include "complextype.icc"
+
+
+
+#endif
diff --git a/relcatalogif/complextype.icc b/relcatalogif/complextype.icc
new file mode 100644
index 0000000..a6ca72c
--- /dev/null
+++ b/relcatalogif/complextype.icc
@@ -0,0 +1,159 @@
+/*
+* 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>.
+*/
+///////////////////////////////////////////////////////////////
+// implementation - ComplexType1
+///////////////////////////////////////////////////////////////
+
+
+inline ComplexType1::ComplexType1()
+ : GenericComplexType(ComplexType1::Name, 2 * sizeof(float)), reOffset(0), imOffset(sizeof(float)) {
+ myType = COMPLEXTYPE1;
+ myOId = OId(COMPLEXTYPE1, OId::ATOMICTYPEOID);
+}
+
+inline ComplexType1::ComplexType1(const OId& id) throw (r_Error)
+ : GenericComplexType(id), reOffset(0), imOffset(sizeof(float)) {
+ readFromDb();
+}
+
+inline ComplexType1::ComplexType1(const ComplexType1& old) : GenericComplexType(old) {
+ reOffset = old.reOffset;
+ imOffset = old.imOffset;
+}
+
+inline ComplexType1& ComplexType1::operator =(const ComplexType1& old) {
+ if(this == &old)
+ return *this;
+ AtomicType::operator =(old);
+ reOffset = old.reOffset;
+ imOffset = old.imOffset;
+ return *this;
+}
+
+inline ComplexType1::~ComplexType1() {}
+
+inline void ComplexType1::printCell( ostream& stream, const char* cell ) const {
+ stream << "( Re: " << *(float *)(cell + reOffset) << "\t";
+ stream << "Im: " << *(float *)(cell + imOffset) << " )\n";
+}
+
+inline void ComplexType1::readFromDb() throw (r_Error) {
+ size = 2 * sizeof(float);
+ setName(ComplexType1::Name);
+ myType = COMPLEXTYPE1;
+ myOId = OId(COMPLEXTYPE1, OId::ATOMICTYPEOID);
+}
+
+inline unsigned int ComplexType1::getReOffset() const { return reOffset; }
+inline unsigned int ComplexType1::getImOffset() const { return imOffset; }
+
+// those would better throw an exception
+inline r_ULong* ComplexType1::convertToCULong(const char*, r_ULong*) const { return 0; }
+inline char* ComplexType1::makeFromCULong(char*, const r_ULong*) const { return 0; }
+inline r_Long* ComplexType1::convertToCLong(const char*, r_Long*) const { return 0; }
+inline char* ComplexType1::makeFromCLong(char*, const r_Long*) const { return 0; }
+
+inline double* ComplexType1::convertToCDouble(const char* cell, double* value) const {
+ *value = *(float*)cell;
+ return value;
+}
+
+inline char* ComplexType1::makeFromCDouble(char* cell, const double* value) const {
+ double dummy = *value;
+ if(dummy > FLT_MAX)
+ dummy = FLT_MAX;
+ if(dummy < -1.0f * FLT_MAX)
+ dummy = -1.0f * FLT_MAX;
+ *(float*)(cell) = dummy;
+ return cell;
+}
+
+inline const char* ComplexType1::getTypeName() const {
+ return "complex";
+}
+
+///////////////////////////////////////////////////////////////
+// implementation - ComplexType2
+///////////////////////////////////////////////////////////////
+
+inline ComplexType2::ComplexType2()
+ : GenericComplexType(ComplexType2::Name, 2 * sizeof(double)), reOffset(0), imOffset(sizeof(double)) {
+ myType = COMPLEXTYPE2;
+ myOId = OId(COMPLEXTYPE2, OId::ATOMICTYPEOID);
+}
+
+inline ComplexType2::ComplexType2(const OId& id) throw (r_Error)
+ : GenericComplexType(id), reOffset(0), imOffset(sizeof(double)) {
+ readFromDb();
+}
+
+inline ComplexType2::ComplexType2(const ComplexType2& old) : GenericComplexType(old) {
+ reOffset = old.reOffset;
+ imOffset = old.imOffset;
+}
+
+inline ComplexType2& ComplexType2::operator =(const ComplexType2& old) {
+ if(this == &old)
+ return *this;
+ AtomicType::operator =(old);
+ reOffset = old.reOffset;
+ imOffset = old.imOffset;
+ return *this;
+}
+
+inline ComplexType2::~ComplexType2() {}
+
+inline void ComplexType2::printCell( ostream& stream, const char* cell ) const {
+ stream << "( Re: " << *(double *)(cell + reOffset) << "\t";
+ stream << "Im: " << *(double *)(cell + imOffset) << " )\n";
+}
+
+inline void ComplexType2::readFromDb() throw (r_Error) {
+ size = 2 * sizeof(double);
+ setName(ComplexType2::Name);
+ myType = COMPLEXTYPE2;
+ myOId = OId(COMPLEXTYPE2, OId::ATOMICTYPEOID);
+}
+
+inline unsigned int ComplexType2::getReOffset() const { return reOffset; }
+inline unsigned int ComplexType2::getImOffset() const { return imOffset; }
+
+// those would better throw an exception
+inline r_ULong* ComplexType2::convertToCULong(const char*, r_ULong*) const { return 0; }
+inline char* ComplexType2::makeFromCULong(char*, const r_ULong*) const { return 0; }
+inline r_Long* ComplexType2::convertToCLong(const char*, r_Long*) const { return 0; }
+inline char* ComplexType2::makeFromCLong(char*, const r_Long*) const { return 0; }
+
+inline double* ComplexType2::convertToCDouble(const char* cell, double* value) const {
+ *value = *(double*)cell;
+ return value;
+}
+
+inline char* ComplexType2::makeFromCDouble(char* cell, const double* value) const {
+ *(double*)(cell) = *value;
+ return cell;
+}
+
+inline const char* ComplexType2::getTypeName() const {
+ return "complexd";
+}
diff --git a/relcatalogif/compositetype.C b/relcatalogif/compositetype.C
new file mode 100644
index 0000000..aefead7
--- /dev/null
+++ b/relcatalogif/compositetype.C
@@ -0,0 +1,104 @@
+/*
+* 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>.
+*/
+/*************************************************************
+ *
+ *
+ * PURPOSE:
+ * uses ODMG-conformant O2 classes
+ *
+ *
+ * COMMENTS:
+ * none
+ *
+ ************************************************************/
+
+static const char rcsid[] = "@(#)catalogif,CompositeType: $Header: /home/rasdev/CVS-repository/rasdaman/relcatalogif/compositetype.C,v 1.6 2003/12/27 23:23:04 rasdev Exp $";
+
+#include "compositetype.hh"
+#include "reladminif/externs.h"
+
+/*************************************************************
+ * Method name...: unsigned int getSize() const
+ *
+ * Arguments.....: none
+ * Return value..: size in d_Octets
+ * Description...: returns size of CompositeType in chars
+ ************************************************************/
+
+unsigned int
+CompositeType::getSize() const
+ {
+ return size;
+ }
+
+/*************************************************************
+ * Method name...: CompositeType();
+ *
+ * Arguments.....: none
+ * Return value..: none
+ * Description...: initializes member variables for an
+ * CompositeType.
+ ************************************************************/
+
+CompositeType::CompositeType()
+ : BaseType("unnamed compositetype"),
+ size(0)
+ {
+ }
+
+CompositeType::CompositeType(unsigned int newSize)
+ : BaseType("unnamed compositetype"),
+ size(newSize)
+ {
+ }
+
+CompositeType::CompositeType(const char* name, unsigned int newSize)
+ : BaseType(name),
+ size(newSize)
+ {
+ }
+
+CompositeType::CompositeType(const CompositeType& old)
+ : BaseType(old),
+ size(old.size)
+ {
+ }
+
+CompositeType::CompositeType(const OId& id) throw (r_Error)
+ : BaseType(id)
+ {
+ }
+
+CompositeType::~CompositeType()
+ {
+ }
+
+CompositeType&
+CompositeType::operator=(const CompositeType& old)
+ {
+ BaseType::operator=(old);
+ size = old.size;
+ return *this;
+ }
+
+
diff --git a/relcatalogif/compositetype.hh b/relcatalogif/compositetype.hh
new file mode 100644
index 0000000..9e07106
--- /dev/null
+++ b/relcatalogif/compositetype.hh
@@ -0,0 +1,99 @@
+/*
+* 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>.
+*/
+// -*-C++-*- (for Emacs)
+
+/*************************************************************
+ *
+ *
+ * PURPOSE:
+ * The CompositeType class is the superclass for all for
+ * composite types (e.g. Octet, ULong) describing the type of a
+ * cell
+ *
+ *
+ * COMMENTS:
+ *
+ ************************************************************/
+
+#ifndef _COMPOSITETYPE_HH_
+#define _COMPOSITETYPE_HH_
+
+#include <iostream>
+#include "basetype.hh"
+
+//@ManMemo: Module: {\bf relcatalogif}.
+
+/*@Doc:
+CompositeType is the abstract base class for all structured
+\Ref{BaseType} subclasses, at the moment only \Ref{StructType}.
+*/
+
+class CompositeType : public BaseType
+{
+public:
+ virtual unsigned int getSize() const;
+ /*@Doc:
+ get size of cells of this base type.
+ */
+
+ CompositeType();
+ /*@Doc:
+ constructor.
+ */
+
+ CompositeType(const OId& id) throw (r_Error);
+ /*@Doc:
+ constructor.
+ */
+
+ CompositeType(const CompositeType& old);
+ /*@Doc:
+ constructor.
+ */
+
+ CompositeType(unsigned int newSize);
+ /*@Doc:
+ constructor.
+ */
+
+ virtual ~CompositeType();
+ /*@Doc:
+ virtual destructor needed because of subclasses
+ */
+
+ CompositeType& operator=(const CompositeType& old);
+ /*@Doc:
+ */
+
+protected:
+ unsigned int size;
+ /*@Doc:
+ size of one cell of this base type in number of chars.
+ */
+
+ CompositeType(const char* name, unsigned int newSize);
+ /*@Doc:
+ */
+};
+
+#endif
diff --git a/relcatalogif/dbminterval.hh b/relcatalogif/dbminterval.hh
new file mode 100644
index 0000000..c871cef
--- /dev/null
+++ b/relcatalogif/dbminterval.hh
@@ -0,0 +1,103 @@
+/*
+* 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>.
+*/
+#ifndef _DBMINTERVAL_HH_
+#define _DBMINTERVAL_HH_
+
+class DBMinterval;
+
+template<class T> class DBRef;
+typedef DBRef<DBMinterval> DBMintervalId;
+
+#include "reladminif/dbobject.hh"
+#include "raslib/minterval.hh"
+
+
+//@ManMemo: Module: {\bf relcatalogif}.
+
+/*@Doc:
+Persistent version of r_Minterval. it stores its attributes not very efficient.
+it is used by DBMDDObj and MDDDomainType because the performance impact is neglectabel.
+
+for a more efficient storage system refere to InlineMInterval
+*/
+
+class DBMinterval : public DBObject, public r_Minterval
+ {
+ public:
+ DBMinterval();
+
+ DBMinterval(const OId& id) throw (r_Error);
+
+ DBMinterval(r_Dimension dim);
+
+ DBMinterval(const char* dom);
+
+ DBMinterval(const r_Minterval& old);
+
+ DBMinterval(const DBMinterval& old);
+
+ ~DBMinterval();
+ /*@Doc:
+ validates the object in the database.
+ */
+
+ virtual DBMinterval& operator=(const DBMinterval& old);
+ /*@Doc:
+ replaces only the r_Minterval part of the object
+ */
+
+ virtual DBMinterval& operator=(const r_Minterval& old);
+ /*@Doc:
+ replaces only the r_Minterval part of the object
+ */
+
+ virtual r_Bytes getMemorySize() const;
+ /*@Doc:
+ esimates the space taken up by this object with:
+ DBObject::getMemorySize() + sizeof(r_Minterval)
+ + dimensionality * (4 + 4 + 1 + 1)
+ */
+
+ protected:
+
+ virtual void insertInDb() throw (r_Error);
+ /*@Doc:
+ inserts the object into the database. it uses one table
+ for the fixed length attributes (oid, size, dimension) and
+ another for dynamic data (lower/upper bounds/fixed ranges)
+ */
+
+ virtual void updateInDb() throw (r_Error);
+ /*@Doc:
+ */
+
+ virtual void deleteFromDb() throw (r_Error);
+ /*@Doc:
+ */
+
+ virtual void readFromDb() throw (r_Error);
+ /*@Doc:
+ */
+ };
+
+#endif
diff --git a/relcatalogif/dbminterval.lis b/relcatalogif/dbminterval.lis
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/relcatalogif/dbminterval.lis
diff --git a/relcatalogif/dbminterval.pgc b/relcatalogif/dbminterval.pgc
new file mode 100644
index 0000000..eaddf10
--- /dev/null
+++ b/relcatalogif/dbminterval.pgc
@@ -0,0 +1,381 @@
+/*
+* 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:
+ * Code with embedded SQL for PostgreSQL DBMS
+ *
+ *
+ * COMMENTS:
+ * none
+ *
+ ***********************************************************************/
+
+#include "reladminif/sqlerror.hh"
+#include "reladminif/externs.h"
+#include "dbminterval.hh"
+#include "raslib/rmdebug.hh"
+
+EXEC SQL include "../reladminif/sqlglobals.h";
+
+DBMinterval::DBMinterval()
+ : r_Minterval(),
+ DBObject()
+{
+ objecttype = OId::DBMINTERVALOID;
+}
+
+DBMinterval::DBMinterval(const OId& id) throw (r_Error)
+ : r_Minterval(),
+ DBObject(id)
+{
+ objecttype = OId::DBMINTERVALOID;
+ readFromDb();
+}
+
+DBMinterval::DBMinterval(r_Dimension dim)
+ : r_Minterval(dim),
+ DBObject()
+{
+ objecttype = OId::DBMINTERVALOID;
+}
+
+DBMinterval::DBMinterval(const char* dom)
+ : r_Minterval((char*)dom),
+ DBObject()
+{
+ objecttype = OId::DBMINTERVALOID;
+}
+
+DBMinterval::DBMinterval(const DBMinterval& old)
+ : r_Minterval(old),
+ DBObject(old)
+{
+ objecttype = OId::DBMINTERVALOID;
+}
+
+DBMinterval::DBMinterval(const r_Minterval& old)
+ : r_Minterval(old),
+ DBObject()
+{
+ objecttype = OId::DBMINTERVALOID;
+}
+
+DBMinterval::~DBMinterval()
+{
+ RMDBGENTER(4, RMDebug::module_catalogif, "DBMinterval", "~DBMinterval() " << myOId);
+ validate();
+ RMDBGEXIT(4, RMDebug::module_catalogif, "DBMinterval", "~DBMinterval() " << myOId);
+}
+
+DBMinterval&
+DBMinterval::operator=(const DBMinterval& old)
+{
+ RMDBGENTER(11, RMDebug::module_catalogif, "DBMinterval", "operator=(" << old.getOId() << ") with me " << myOId);
+ if (this == &old)
+ return *this;
+ r_Minterval::operator=(old);
+ setModified();
+ RMDBGEXIT(11, RMDebug::module_catalogif, "DBMinterval", "operator=(" << old.getOId() << ") with me " << myOId);
+ return *this;
+}
+
+DBMinterval&
+DBMinterval::operator=(const r_Minterval& old)
+{
+ if (this == &old)
+ return *this;
+ r_Minterval::operator=(old);
+ setModified();
+ return *this;
+}
+
+r_Bytes
+DBMinterval::getMemorySize() const
+{
+ return DBObject::getMemorySize() + sizeof(r_Minterval) + dimensionality * (4 + 4 + 1 + 1);
+}
+
+void
+DBMinterval::insertInDb() throw (r_Error)
+{
+ EXEC SQL BEGIN DECLARE SECTION;
+ long domainid;
+ long count;
+ long low;
+ short lowind;
+ long high;
+ short highind;
+ long dimension;
+ EXEC SQL END DECLARE SECTION;
+
+ domainid = myOId.getCounter();
+ dimension = dimensionality;
+
+ EXEC SQL INSERT INTO RAS_DOMAINS ( DomainId, Dimension)
+ VALUES ( :domainid, :dimension);
+ if (SQLCODE != SQLOK)
+ {
+ check("DBMinterval::insertInDb() INSERT INTO RAS_DOMAINS");
+ generateException();
+ }
+
+ for (count = 0; count < dimensionality; count++)
+ {
+ if (intervals[count].is_low_fixed())
+ {
+ low = intervals[count].low();
+ lowind = 0;
+ }
+ else
+ {
+ lowind = -1;
+ }
+ if (intervals[count].is_high_fixed())
+ {
+ high = intervals[count].high();
+ highind = 0;
+ }
+ else
+ {
+ highind = -1;
+ }
+
+ EXEC SQL INSERT INTO RAS_DOMAINVALUES ( DomainId, DimensionCount, Low, High)
+ VALUES ( :domainid, :count, :low INDICATOR :lowind, :high INDICATOR :highind);
+ if (SQLCODE != SQLOK)
+ {
+ check("DBMinterval::insertInDb() INSERT INTO RAS_DOMAINVALUES");
+ generateException();
+ }
+ }
+
+ DBObject::insertInDb();
+}
+
+void
+DBMinterval::updateInDb() throw (r_Error)
+{
+ EXEC SQL BEGIN DECLARE SECTION;
+ long domainid1;
+ long count1;
+ long low1;
+ short lowind1;
+ long high1;
+ short highind1;
+ long dimension1;
+ EXEC SQL END DECLARE SECTION;
+
+ domainid1 = myOId.getCounter();
+
+ EXEC SQL SELECT Dimension
+ INTO :dimension1
+ FROM RAS_DOMAINS
+ WHERE DomainId = :domainid1;
+
+ if (dimension1 < dimensionality)
+ { //insert more rows in RAS_DOMAINVALUES
+ for (count1 = dimension1; count1 < dimensionality; count1++)
+ {
+ EXEC SQL INSERT INTO RAS_DOMAINVALUES ( DomainId, DimensionCount)
+ VALUES ( :domainid1, :count1);
+ if (SQLCODE != SQLOK)
+ {
+ check("DBMinterval::updateInDb() INSERT INTO RAS_DOMAINVALUES");
+ generateException();
+ }
+ }
+ dimension1 = dimensionality;
+ EXEC SQL UPDATE RAS_DOMAINS SET Dimension = :dimension1
+ WHERE DomainId = :domainid1;
+
+ if (check("DBMinterval::updateInDb() UPDATE RAS_DOMAINS"))
+ generateException();
+ }
+ else
+ {
+ if (dimension1 > dimensionality)
+ { //delete superfluous dimensions
+ for (count1 = dimension1; count1 > dimensionality; count1--)
+ {
+ EXEC SQL DELETE
+ FROM RAS_DOMAINVALUES
+ WHERE DomainId = :domainid1 AND DimensionCount = :count1;
+ if (SQLCODE != SQLOK)
+ {
+ check("DBMinterval::updateInDb() DELETE FROM RAS_DOMAINVALUES");
+ generateException();
+ }
+ }
+ dimension1 = dimensionality;
+ EXEC SQL UPDATE RAS_DOMAINS
+ SET Dimension = :dimension1
+ WHERE DomainId = :domainid1;
+ if (SQLCODE != SQLOK)
+ {
+ check("DBMinterval::updateInDb() UPDATE RAS_DOMAINS");
+ generateException();
+ }
+ }
+ else
+ { //only update dimension boundaries
+ }
+ }
+
+ for (count1 = 0; count1 < dimensionality; count1++)
+ {
+ if (intervals[count1].is_low_fixed())
+ {
+ low1 = intervals[count1].low();
+ lowind1 = 0;
+ }
+ else
+ {
+ lowind1 = -1;
+ }
+ if (intervals[count1].is_high_fixed())
+ {
+ high1 = intervals[count1].high();
+ highind1 = 0;
+ }
+ else
+ {
+ highind1 = -1;
+ }
+
+ EXEC SQL UPDATE RAS_DOMAINVALUES
+ SET Low = :low1 INDICATOR :lowind1, High = :high1 INDICATOR :highind1
+ WHERE DomainId = :domainid1 AND DimensionCount = :count1;
+ if (SQLCODE != SQLOK)
+ {
+ check("DBMinterval::updateInDb() UPDATE RAS_DOMAINVALUES");
+ generateException();
+ }
+ }
+
+ DBObject::updateInDb();
+}
+
+void
+DBMinterval::deleteFromDb() throw (r_Error)
+{
+ EXEC SQL BEGIN DECLARE SECTION;
+ long domainid2;
+ EXEC SQL END DECLARE SECTION;
+
+ domainid2 = myOId.getCounter();
+
+ EXEC SQL DELETE FROM RAS_DOMAINS
+ WHERE DomainId = :domainid2;
+ if (SQLCODE != SQLOK)
+ {
+ check("DBMinterval::deleteFromDb() DELETE FROM RAS_DOMAINS");
+ generateException();
+ }
+
+ EXEC SQL DELETE FROM RAS_DOMAINVALUES
+ WHERE DomainId = :domainid2;
+ if (SQLCODE != SQLOK)
+ {
+ check("DBMinterval::deleteFromDb() DELETE FROM RAS_DOMAINVALUES");
+ generateException();
+ }
+
+ DBObject::deleteFromDb();
+}
+
+void
+DBMinterval::readFromDb() throw (r_Error)
+{
+ char undefined = '*';
+ EXEC SQL BEGIN DECLARE SECTION;
+ long domainid3;
+ long count3;
+ long low3;
+ short lowind3;
+ long high3;
+ short highind3;
+ long dimension3;
+ EXEC SQL END DECLARE SECTION;
+
+ domainid3 = myOId.getCounter();
+
+ EXEC SQL SELECT Dimension
+ INTO :dimension3
+ FROM RAS_DOMAINS
+ WHERE DomainId = :domainid3;
+ if (SQLCODE != SQLOK)
+ {
+ check("DBMinterval::readFromDb() SELECT FROM RAS_DOMAINS");
+ if (SQLCODE == 100)
+ {
+ throw r_Error(r_Error::r_Error_ObjectUnknown);
+ }
+ else
+ {
+ generateException();
+ }
+ }
+
+ dimensionality = dimension3;
+ delete[] intervals;
+ intervals = new r_Sinterval[dimensionality];
+ streamInitCnt = 0;
+
+ for (count3 = 0; count3 < dimension3; count3++)
+ {
+ EXEC SQL SELECT Low, High
+ INTO :low3 INDICATOR :lowind3, :high3 INDICATOR :highind3
+ FROM RAS_DOMAINVALUES
+ WHERE DimensionCount = :count3 AND DomainId = :domainid3;
+ if (SQLCODE != SQLOK)
+ {
+ check("DBMinterval::readFromDb() SELECT FROM RAS_DOMAINVALUES");
+ generateException();
+ }
+
+ if (!lowind3)
+ {
+ intervals[count3].set_low((r_Range)low3);
+ }
+ else
+ {
+ intervals[count3].set_low(undefined);
+ }
+ if (!highind3)
+ {
+ intervals[count3].set_high((r_Range)high3);
+ }
+ else
+ {
+ intervals[count3].set_high(undefined);
+ }
+ streamInitCnt++;
+ }
+
+ DBObject::readFromDb();
+}
+
diff --git a/relcatalogif/doubletype.C b/relcatalogif/doubletype.C
new file mode 100644
index 0000000..0258c1a
--- /dev/null
+++ b/relcatalogif/doubletype.C
@@ -0,0 +1,154 @@
+/*
+* 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>.
+*/
+/*************************************************************
+ *
+ *
+ * PURPOSE:
+ * uses ODMG-conformant O2 classes
+ *
+ *
+ * COMMENTS:
+ * none
+ *
+ ************************************************************/
+
+static const char rcsid[] = "@(#)catalogif,DoubleType: $Header: /home/rasdev/CVS-repository/rasdaman/relcatalogif/doubletype.C,v 1.8 2003/12/27 23:23:04 rasdev Exp $";
+
+#include "doubletype.hh"
+#include <iomanip>
+#include <string.h>
+
+DoubleType::DoubleType(const OId& id) throw (r_Error)
+ : RealType(id)
+ {
+ readFromDb();
+ }
+
+/*************************************************************
+ * Method name...: DoubleType();
+ *
+ * Arguments.....: none
+ * Return value..: none
+ * Description...: initializes member variables for an
+ * DoubleType.
+ ************************************************************/
+
+DoubleType::DoubleType()
+ : RealType(DoubleType::Name, 8)
+ {
+ myType = DOUBLE;
+ myOId = OId(DOUBLE, OId::ATOMICTYPEOID);
+ }
+
+/*************************************************************
+ * Method name...: DoubleType(const DoubleType& old);
+ *
+ * Arguments.....: none
+ * Return value..: none
+ * Description...: copy constructor
+ ************************************************************/
+
+DoubleType::DoubleType(const DoubleType& old) :
+ RealType(old)
+{
+}
+
+/*************************************************************
+ * Method name...: operator=(const DoubleType&);
+ *
+ * Arguments.....: none
+ * Return value..: none
+ * Description...: copy constructor
+ ************************************************************/
+
+DoubleType&
+DoubleType::operator=(const DoubleType& old)
+ {
+ // Gracefully handle self assignment
+ if (this == &old)
+ return *this;
+ AtomicType::operator=(old);
+ return *this;
+ }
+
+/*************************************************************
+ * Method name...: ~DoubleType();
+ *
+ * Arguments.....: none
+ * Return value..: none
+ * Description...: virtual destructor
+ ************************************************************/
+
+DoubleType::~DoubleType()
+{
+}
+
+void
+DoubleType::readFromDb() throw (r_Error)
+ {
+ size = 8;
+ setName(DoubleType::Name);
+ myType = DOUBLE;
+ myOId = OId(DOUBLE, OId::ATOMICTYPEOID);
+ }
+
+/*************************************************************
+ * Method name...: void printCell( ostream& stream,
+ * const char* cell )
+ *
+ * Arguments.....:
+ * stream: stream to print on
+ * cell: pointer to cell to print
+ * Return value..: none
+ * Description...: prints a cell cell in hex on stream
+ * followed by a space.
+ * Assumes that Double is stored MSB..LSB
+ * on HP.
+ ************************************************************/
+
+void
+DoubleType::printCell( ostream& stream, const char* cell ) const
+{
+ // !!!! HP specific, assumes 4 Byte double and MSB..LSB
+ // byte order
+ stream << *(double*)cell << " ";
+}
+
+double*
+DoubleType::convertToCDouble(const char* cell, double* value) const
+{
+ // !!!! HP specific, assumes 8 Byte double
+ // byte order
+ *value = *(double*)cell;
+ return value;
+}
+
+
+char*
+DoubleType::makeFromCDouble(char* cell, const double* value) const
+{
+ // !!!! HP specific, assumes 4 Byte double and MSB..LSB
+ // byte order
+ *(double*)(cell) = *value;
+ return cell;
+}
diff --git a/relcatalogif/doubletype.hh b/relcatalogif/doubletype.hh
new file mode 100644
index 0000000..74dcfa2
--- /dev/null
+++ b/relcatalogif/doubletype.hh
@@ -0,0 +1,103 @@
+/*
+* 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>.
+*/
+// -*-C++-*- (for Emacs)
+
+/*************************************************************
+ *
+ *
+ * PURPOSE:
+ * The DoubleType class is the superclass for all classes
+ * describing the type of a cell
+ *
+ *
+ * COMMENTS:
+ *
+ ************************************************************/
+
+#ifndef _DOUBLETYPE_HH_
+#define _DOUBLETYPE_HH_
+
+#include <iostream>
+#include "realtype.hh"
+#include "catalogmgr/ops.hh"
+
+class OId;
+
+//@ManMemo: Module: {\bf relcatalogif}.
+
+/*@Doc:
+DoubleType is the base type used for 32bit integer cell
+values. The value of a Double is stored in four chars.
+*/
+
+class DoubleType : public RealType
+ {
+ public:
+ DoubleType();
+ /*@Doc:
+ default constructor, sets type name to "Double".
+ */
+
+ DoubleType(const OId& id) throw (r_Error);
+ /*@Doc:
+ */
+
+ DoubleType(const DoubleType& old);
+ /*@Doc:
+ copy constructor.
+ */
+
+ DoubleType& operator=(const DoubleType& old);
+ /*@Doc:
+ assignment operator.
+ */
+
+ virtual ~DoubleType();
+ /*@Doc:
+ virtual destructor.
+ */
+
+ virtual void printCell(ostream& stream, const char* cell) const;
+ /*@Doc:
+ */
+
+ virtual double* convertToCDouble(const char* cell, double* value) const;
+ /*@Doc:
+ */
+
+ virtual char* makeFromCDouble(char* cell, const double* value) const;
+ /*@Doc:
+ */
+
+ static const char* Name;
+
+ protected:
+
+ virtual void readFromDb() throw (r_Error);
+ /*@Doc:
+ initializes the attributes of this type.
+ there is no database activity. this is hard coded.
+ */
+ };
+
+#endif
diff --git a/relcatalogif/floattype.C b/relcatalogif/floattype.C
new file mode 100644
index 0000000..f043dd9
--- /dev/null
+++ b/relcatalogif/floattype.C
@@ -0,0 +1,159 @@
+/*
+* 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>.
+*/
+/*************************************************************
+ *
+ *
+ * PURPOSE:
+ * uses ODMG-conformant O2 classes
+ *
+ *
+ * COMMENTS:
+ * none
+ *
+ ************************************************************/
+
+static const char rcsid[] = "@(#)catalogif,FloatType: $Header: /home/rasdev/CVS-repository/rasdaman/relcatalogif/floattype.C,v 1.10 2003/12/27 23:23:04 rasdev Exp $";
+
+#include "floattype.hh"
+#include <iomanip>
+#include <string.h>
+#include "reladminif/oidif.hh"
+#include <values.h>
+
+FloatType::FloatType(const OId& id) throw (r_Error)
+ : RealType(id)
+ {
+ readFromDb();
+ }
+
+/*************************************************************
+ * Method name...: FloatType();
+ *
+ * Arguments.....: none
+ * Return value..: none
+ * Description...: initializes member variables for an
+ * FloatType.
+ ************************************************************/
+
+FloatType::FloatType()
+ : RealType(FloatType::Name, 4)
+ {
+ myType = FLOAT;
+ myOId = OId(FLOAT, OId::ATOMICTYPEOID);
+ }
+
+/*************************************************************
+ * Method name...: FloatType(const FloatType& old);
+ *
+ * Arguments.....: none
+ * Return value..: none
+ * Description...: copy constructor
+ ************************************************************/
+
+FloatType::FloatType(const FloatType& old)
+ : RealType(old)
+ {
+ }
+
+/*************************************************************
+ * Method name...: operator=(const FloatType&);
+ *
+ * Arguments.....: none
+ * Return value..: none
+ * Description...: copy constructor
+ ************************************************************/
+
+FloatType& FloatType::operator=(const FloatType& old)
+ {
+ // Gracefully handle self assignment
+ if (this == &old)
+ return *this;
+ AtomicType::operator=(old);
+ return *this;
+ }
+
+/*************************************************************
+ * Method name...: ~FloatType();
+ *
+ * Arguments.....: none
+ * Return value..: none
+ * Description...: virtual destructor
+ ************************************************************/
+
+FloatType::~FloatType()
+{
+}
+
+void
+FloatType::readFromDb() throw (r_Error)
+ {
+ setName(FloatType::Name);
+ size = 4;
+ myType = FLOAT;
+ myOId = OId(FLOAT, OId::ATOMICTYPEOID);
+ }
+
+/*************************************************************
+ * Method name...: void printCell( ostream& stream,
+ * const char* cell )
+ *
+ * Arguments.....:
+ * stream: stream to print on
+ * cell: pointer to cell to print
+ * Return value..: none
+ * Description...: prints a cell cell in hex on stream
+ * followed by a space.
+ * Assumes that Float is stored MSB..LSB
+ * on HP.
+ ************************************************************/
+
+void
+FloatType::printCell( ostream& stream, const char* cell ) const
+{
+ // !!!! HP specific, assumes 4 Byte float and MSB..LSB
+ // byte order
+ stream << std::setw(8) << *(float*)cell;
+}
+
+double*
+FloatType::convertToCDouble(const char* cell, double* value) const
+{
+ // !!!! HP specific, assumes 4 Byte float and MSB..LSB
+ // byte order
+ *value = *(float*)cell;
+ return value;
+}
+
+
+char*
+FloatType::makeFromCDouble(char* cell, const double* value) const
+{
+ // make sure that a float is not assigned a double (DEC Alpha correctly dumps core)
+ double dummy = *value;
+ if(dummy > FLT_MAX)
+ dummy = FLT_MAX;
+ if(dummy < -1.0f * FLT_MAX)
+ dummy = -1.0f * FLT_MAX;
+ *(float*)(cell) = dummy;
+ return cell;
+}
diff --git a/relcatalogif/floattype.hh b/relcatalogif/floattype.hh
new file mode 100644
index 0000000..299fe11
--- /dev/null
+++ b/relcatalogif/floattype.hh
@@ -0,0 +1,95 @@
+/*
+* 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>.
+*/
+// -*-C++-*- (for Emacs)
+
+/*************************************************************
+ *
+ *
+ * PURPOSE:
+ * The FloatType class is the superclass for all classes
+ * describing the type of a cell
+ *
+ *
+ * COMMENTS:
+ *
+ ************************************************************/
+
+#ifndef _FLOATTYPE_HH_
+#define _FLOATTYPE_HH_
+
+#include <iostream>
+#include "realtype.hh"
+#include "catalogmgr/ops.hh"
+
+class OId;
+
+//@ManMemo: Module: {\bf relcatalogif}.
+
+/*@Doc:
+FloatType is the base type used for 32bit integer cell
+values. The value of a Float is stored in four chars.
+*/
+
+class FloatType : public RealType
+ {
+ public:
+ FloatType(const OId& id) throw (r_Error);
+
+ FloatType();
+ /*@Doc:
+ default constructor, sets type name to "Float".
+ */
+
+ FloatType(const FloatType& old);
+ /*@Doc:
+ copy constructor.
+ */
+
+ FloatType& operator=(const FloatType& old);
+ /*@Doc:
+ assignment operator.
+ */
+
+ virtual ~FloatType();
+ /*@Doc:
+ virtual destructor.
+ */
+
+ virtual void printCell(ostream& stream, const char* cell) const;
+
+ virtual double* convertToCDouble(const char* cell, double* value) const;
+
+ virtual char* makeFromCDouble(char* cell, const double* value) const;
+
+ static const char* Name;
+
+ protected:
+
+ virtual void readFromDb() throw (r_Error);
+ /*@Doc:
+ initializes the attributes of this type.
+ there is no database activity. this is hard coded.
+ */
+ };
+
+#endif
diff --git a/relcatalogif/inlineminterval.cc b/relcatalogif/inlineminterval.cc
new file mode 100644
index 0000000..05d14d3
--- /dev/null
+++ b/relcatalogif/inlineminterval.cc
@@ -0,0 +1,139 @@
+/*
+* 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++ -*-
+/*
+ * dbminterval.pc
+ *
+ * 17-May-99 hoefner First created.
+ * 27-May-99 webbasan Added prefix "RAS_" to tablenames.
+ */
+
+#include "inlineminterval.hh"
+#include "raslib/rmdebug.hh"
+
+InlineMinterval::InlineMinterval()
+ : r_Minterval((r_Dimension)0)
+ {
+ RMDBGONCE(10, RMDebug::module_catalogif, "InlineMinterval", "InlineMinterval()");
+ }
+
+InlineMinterval::~InlineMinterval()
+ {
+ RMDBGONCE(10, RMDebug::module_catalogif, "InlineMinterval", "~InlineMinterval()");
+ }
+
+InlineMinterval::InlineMinterval(r_Dimension dim)
+ : r_Minterval(dim)
+ {
+ RMDBGONCE(10, RMDebug::module_catalogif, "InlineMinterval", "InlineMinterval(" << dim << ")");
+ }
+
+InlineMinterval::InlineMinterval(r_Dimension dim, r_Range* lowerbound, r_Range* upperbound, char* lowerfixed, char* upperfixed)
+ : r_Minterval(dim)
+ {
+ RMDBGENTER(10, RMDebug::module_catalogif, "InlineMinterval", "InlineMinterval(" << dim << ", lb, ub, lf, uf)");
+ char undefined = '*';
+ streamInitCnt = dim;
+
+ for (r_Dimension count = 0; count < dimensionality; count++)
+ {
+ if (!lowerfixed[count])
+ {
+ intervals[count].set_high(undefined);
+ intervals[count].set_low(lowerbound[count]);
+ }
+ else {
+ intervals[count].set_low(undefined);
+ }
+ if (!upperfixed[count])
+ {
+ intervals[count].set_high(upperbound[count]);
+ }
+ else {
+ intervals[count].set_high(undefined);
+ }
+ }
+ RMDBGEXIT(10, RMDebug::module_catalogif, "InlineMinterval", "InlineMinterval(" << dim << ", lb, ub, lf, uf)");
+ }
+
+InlineMinterval::InlineMinterval(const InlineMinterval& old)
+ : r_Minterval(old)
+ {
+ RMDBGONCE(10, RMDebug::module_catalogif, "InlineMinterval", "InlineMinterval(InlineMinterval)");
+ }
+
+InlineMinterval::InlineMinterval(const r_Minterval& old)
+ : r_Minterval(old)
+ {
+ RMDBGONCE(10, RMDebug::module_catalogif, "InlineMinterval", "InlineMinterval(r_Minterval)");
+ }
+
+InlineMinterval&
+InlineMinterval::operator=(const InlineMinterval& old)
+ {
+ RMDBGENTER(10, RMDebug::module_catalogif, "InlineMinterval", "operator=()");
+ if (this == &old)
+ return *this;
+ r_Minterval::operator=(old);
+ RMDBGEXIT(10, RMDebug::module_catalogif, "InlineMinterval", "operator=()");
+ return *this;
+ }
+
+InlineMinterval&
+InlineMinterval::operator=(const r_Minterval& old)
+ {
+ RMDBGENTER(10, RMDebug::module_catalogif, "InlineMinterval", "operator=()");
+ if (this == &old)
+ return *this;
+ r_Minterval::operator=(old);
+ RMDBGEXIT(10, RMDebug::module_catalogif, "InlineMinterval", "operator=()");
+ return *this;
+ }
+
+void
+InlineMinterval::insertInDb(r_Range* lowerbound, r_Range* upperbound, char* lowerfixed, char* upperfixed) const
+ {
+ RMDBGENTER(10, RMDebug::module_catalogif, "InlineMinterval", "insertInDb(lb, ub, lf, uf)");
+ char undefined = '*';
+ for (int count = 0; count < dimensionality; count++)
+ {
+ if (intervals[count].is_low_fixed())
+ {
+ lowerbound[count] = intervals[count].low();
+ lowerfixed[count] = 0;
+ }
+ else {
+ lowerfixed[count] = undefined;
+ }
+ if (intervals[count].is_high_fixed())
+ {
+ upperbound[count] = intervals[count].high();
+ upperfixed[count] = 0;
+ }
+ else {
+ upperfixed[count] = undefined;
+ }
+ }
+ RMDBGEXIT(10, RMDebug::module_catalogif, "InlineMinterval", "insertInDb(lb, ub, lf, uf)");
+ }
+
diff --git a/relcatalogif/inlineminterval.hh b/relcatalogif/inlineminterval.hh
new file mode 100644
index 0000000..c3f1daa
--- /dev/null
+++ b/relcatalogif/inlineminterval.hh
@@ -0,0 +1,73 @@
+/*
+* 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>.
+*/
+#ifndef _INLINEMINTERVAL_HH_
+#define _INLINEMINTERVAL_HH_
+
+class InlineMinterval;
+
+template<class T> class DBRef;
+
+#include "raslib/minterval.hh"
+
+//@ManMemo: Module: {\bf relcatalogif}.
+
+/*@Doc:
+InlineMinterval is a subclass of r_Minterval which stores and
+instantiates itself in char[].
+This class is used by the index data structures to store their
+domain data fast and efficiently.
+*/
+
+class InlineMinterval : public r_Minterval
+ {
+ public:
+ InlineMinterval();
+
+ InlineMinterval(r_Dimension dim);
+
+ InlineMinterval(r_Dimension dim, r_Range* lowerbound, r_Range* upperbound, char* lowerfixed, char* upperfixed);
+ /*@Doc:
+ construct a InlineMinterval with dimension dim from the
+ arrays lowerbound, upperbound, lowerfixed, upperfixed.
+ */
+
+ InlineMinterval(const r_Minterval& old);
+
+ InlineMinterval(const InlineMinterval& old);
+
+ virtual ~InlineMinterval();
+
+ //replaces only the r_Minterval part of the object
+ virtual InlineMinterval& operator=(const InlineMinterval& old);
+
+ //replaces only the r_Minterval part of the object
+ virtual InlineMinterval& operator=(const r_Minterval& old);
+
+ virtual void insertInDb(r_Range* lowerbound, r_Range* upperbound, char* lowerfixed, char* upperfixed) const;
+ /*@Doc:
+ stores the attributes of the InlineMinterval into the four
+ supplied arrays. the arrays must be large enough.
+ */
+ };
+
+#endif
diff --git a/relcatalogif/integraltype.hh b/relcatalogif/integraltype.hh
new file mode 100644
index 0000000..118056e
--- /dev/null
+++ b/relcatalogif/integraltype.hh
@@ -0,0 +1,89 @@
+/*
+* 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>.
+*/
+/*************************************************************
+ *
+ *
+ * PURPOSE:
+ * The IntegralType class is the superclass for all signed integral
+ * types (e.g. Char, Long) describing the type of a
+ * cell
+ *
+ *
+ * COMMENTS:
+ *
+ ************************************************************/
+
+#ifndef _INTEGRALTYPE_HH_
+#define _INTEGRALTYPE_HH_
+
+#include "atomictype.hh"
+
+//@ManMemo: Module: {\bf relcatalogif}.
+
+/*@Doc:
+IntegralType is the abstract base class for all integral signed
+\Ref{BaseType} subclasses, i.e. base types like \Ref{LongType} or
+\Ref{ShortType}. It provides conversions to/from unsigned and
+double. It's subclasses must implement conversions to/from long.
+*/
+
+class IntegralType : public AtomicType {
+public:
+ IntegralType(unsigned int newSize):
+ AtomicType(newSize) {}
+ /*@Doc:
+ constructor.
+ */
+
+ IntegralType(const IntegralType& old):
+ AtomicType(old) {}
+ /*@Doc:
+ copy constructor.
+ */
+
+ IntegralType(const OId& id) throw (r_Error):
+ AtomicType(id) {}
+ /*@Doc:
+ */
+
+ virtual ~IntegralType() {}
+ /*@Doc:
+ */
+
+ virtual r_ULong* convertToCULong(const char*, r_ULong*) const;
+ virtual char* makeFromCULong(char*, const r_ULong*) const;
+
+ virtual double* convertToCDouble(const char*, double*) const;
+ virtual char* makeFromCDouble(char*, const double*) const;
+
+protected:
+ IntegralType(const char* name, unsigned int newSize):
+ AtomicType(name, newSize) {}
+ /*@Doc:
+ */
+
+};
+
+#include "integraltype.icc"
+
+#endif
diff --git a/relcatalogif/integraltype.icc b/relcatalogif/integraltype.icc
new file mode 100644
index 0000000..f74cfa6
--- /dev/null
+++ b/relcatalogif/integraltype.icc
@@ -0,0 +1,53 @@
+/*
+* 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>.
+*/
+/*************************************************************
+*
+*
+* COMMENTS:
+*
+************************************************************/
+
+
+
+inline r_ULong*
+IntegralType::convertToCULong(const char* cell, r_ULong* value) const {
+ return (r_ULong*)(this->convertToCLong(cell, (r_Long *)value));
+}
+
+inline double*
+IntegralType::convertToCDouble(const char* cell, double* value) const {
+ r_Long tmp;
+ *value = *this->convertToCLong(cell, &tmp);
+ return value;
+}
+
+inline char*
+IntegralType::makeFromCULong(char* cell, const r_ULong* value) const {
+ return this->makeFromCLong(cell, (r_Long *)value);
+}
+
+inline char*
+IntegralType::makeFromCDouble(char* cell, const double* value) const {
+ r_Long tmp = *value;
+ return this->makeFromCLong(cell, &tmp);
+}
diff --git a/relcatalogif/longtype.C b/relcatalogif/longtype.C
new file mode 100644
index 0000000..765ea65
--- /dev/null
+++ b/relcatalogif/longtype.C
@@ -0,0 +1,147 @@
+/*
+* 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>.
+*/
+/*************************************************************
+ *
+ *
+ * PURPOSE:
+ * uses ODMG-conformant O2 classes
+ *
+ *
+ * COMMENTS:
+ * none
+ *
+ ************************************************************/
+
+static const char rcsid[] = "@(#)catalogif,LongType: $Header: /home/rasdev/CVS-repository/rasdaman/relcatalogif/longtype.C,v 1.9 2003/12/27 23:23:04 rasdev Exp $";
+
+#include "longtype.hh"
+#include <iomanip>
+#include <string.h>
+
+LongType::LongType(const OId& id) throw (r_Error)
+ : IntegralType(id)
+ {
+ readFromDb();
+ }
+
+/*************************************************************
+ * Method name...: LongType();
+ *
+ * Arguments.....: none
+ * Return value..: none
+ * Description...: initializes member variables for an
+ * LongType.
+ ************************************************************/
+
+LongType::LongType()
+ : IntegralType(LongType::Name, 4)
+ {
+ myType = LONG;
+ myOId = OId(LONG, OId::ATOMICTYPEOID);
+ }
+
+void
+LongType::readFromDb() throw (r_Error)
+ {
+ setName(LongType::Name);
+ size = 4;
+ myType = LONG;
+ myOId = OId(LONG, OId::ATOMICTYPEOID);
+ }
+
+/*************************************************************
+ * Method name...: LongType(const LongType& old);
+ *
+ * Arguments.....: none
+ * Return value..: none
+ * Description...: copy constructor
+ ************************************************************/
+
+LongType::LongType(const LongType& old)
+ : IntegralType(old)
+ {
+ }
+
+/*************************************************************
+ * Method name...: operator=(const LongType&);
+ *
+ * Arguments.....: none
+ * Return value..: none
+ * Description...: copy constructor
+ ************************************************************/
+
+LongType& LongType::operator=(const LongType& old)
+ {
+ // Gracefully handle self assignment
+ if (this == &old)
+ return *this;
+ AtomicType::operator=(old);
+ return *this;
+ }
+
+/*************************************************************
+ * Method name...: ~LongType();
+ *
+ * Arguments.....: none
+ * Return value..: none
+ * Description...: virtual destructor
+ ************************************************************/
+
+LongType::~LongType()
+{
+}
+
+/*************************************************************
+ * Method name...: void printCell( ostream& stream,
+ * const char* cell )
+ *
+ * Arguments.....:
+ * stream: stream to print on
+ * cell: pointer to cell to print
+ * Return value..: none
+ * Description...: prints a cell cell in hex on stream
+ * followed by a space.
+ * Assumes that Long is stored MSB..LSB
+ * on HP.
+ ************************************************************/
+
+void
+LongType::printCell( ostream& stream, const char* cell ) const
+{
+ stream << std::setw(8) << *(r_Long*)cell;
+}
+
+r_Long*
+LongType::convertToCLong(const char* cell, r_Long* value) const
+{
+ *value = *(r_Long*)cell;
+ return value;
+}
+
+
+char*
+LongType::makeFromCLong(char* cell, const r_Long* value) const
+{
+ *(r_Long*)(cell) = *value;
+ return cell;
+}
diff --git a/relcatalogif/longtype.hh b/relcatalogif/longtype.hh
new file mode 100644
index 0000000..4aa5573
--- /dev/null
+++ b/relcatalogif/longtype.hh
@@ -0,0 +1,106 @@
+/*
+* 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>.
+*/
+// -*-C++-*- (for Emacs)
+
+/*************************************************************
+ *
+ *
+ * PURPOSE:
+ * The LongType class is the superclass for all classes
+ * describing the type of a cell
+ *
+ *
+ * COMMENTS:
+ *
+ ************************************************************/
+
+#ifndef _LONGTYPE_HH_
+#define _LONGTYPE_HH_
+
+#include <iostream>
+#include "integraltype.hh"
+#include "catalogmgr/ops.hh"
+
+class OId;
+
+//@ManMemo: Module: {\bf relcatalogif}.
+
+/*@Doc:
+LongType is the base type used for 32bit integer cell
+values. The value of a Long is stored in four chars.
+
+*/
+
+class LongType : public IntegralType
+ {
+ public:
+ LongType(const OId& id) throw (r_Error);
+ /*@Doc:
+ */
+
+ LongType();
+ /*@Doc:
+ default constructor, sets type name to "Long".
+ */
+
+ LongType(const LongType& old);
+ /*@Doc:
+ copy constructor.
+ */
+
+ LongType& operator=(const LongType& old);
+ /*@Doc:
+ assignment operator.
+ */
+
+ virtual ~LongType();
+ /*@Doc:
+ virtual destructor.
+ */
+
+ virtual void printCell(ostream& stream, const char* cell) const;
+ /*@Doc:
+ there is concern about the MSB..LSB problem in the source code.
+ */
+
+ virtual r_Long* convertToCLong(const char* cell, r_Long* value) const;
+ /*@Doc:
+ */
+
+ virtual char* makeFromCLong(char* cell, const r_Long* value) const;
+ /*@Doc:
+ */
+
+ static const char* Name;
+
+ protected:
+
+ virtual void readFromDb() throw (r_Error);
+ /*@Doc:
+ initializes the attributes of this type.
+ there is no database activity. this is hard coded.
+ */
+
+ };
+
+#endif
diff --git a/relcatalogif/mddbasetype.hh b/relcatalogif/mddbasetype.hh
new file mode 100644
index 0000000..1e1642f
--- /dev/null
+++ b/relcatalogif/mddbasetype.hh
@@ -0,0 +1,142 @@
+/*
+* 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>.
+*/
+// -*-C++-*- (for Emacs)
+
+/*************************************************************
+ *
+ *
+ * PURPOSE:
+ * The MDDBaseType class is used as a type for MDDs where
+ * only the base type is specified.
+ *
+ *
+ * COMMENTS:
+ *
+ ************************************************************/
+
+#ifndef _MDDBASETYPE_HH_
+#define _MDDBASETYPE_HH_
+
+class MDDBaseType;
+
+#include "catalogmgr/ops.hh"
+#include "mddtype.hh"
+
+class OId;
+
+//@ManMemo: Module: {\bf relcatalogif}.
+
+/*@Doc:
+ The MDDBaseType class is used as a type for MDDs when
+ only the base type is specified.
+*/
+
+class MDDBaseType : public MDDType
+ {
+ public:
+ virtual char* getTypeStructure() const;
+ /*@Doc:
+ returns a string: marray < myBaseType->getTypeStructure >
+ */
+
+ MDDBaseType(const OId& id) throw (r_Error);
+ /*@Doc:
+ constructs a MDDBaseType out of the database.
+ */
+
+ MDDBaseType(const char* newTypeName, const BaseType* newBaseType);
+ /*@Doc:
+ constructor.
+ */
+
+ MDDBaseType();
+ /*@Doc:
+ default constructor, cannot be used.
+ */
+
+
+ MDDBaseType(const char* newtypename);
+ /*@Doc:
+ */
+
+ MDDBaseType(const MDDBaseType& old);
+ /*@Doc:
+ copy constructor.
+ */
+
+ MDDBaseType& operator=(const MDDBaseType& old);
+ /*@Doc:
+ assignment operator.
+ */
+
+ const BaseType* getBaseType() const;
+ /*@Doc:
+ returns base type.
+ */
+
+ virtual void print_status( ostream& s ) const;
+ /*@Doc:
+ writes the state of the object to the specified stream:
+ \tr_Marray < myBaseType->getTypeName() \t>
+ */
+
+ virtual ~MDDBaseType();
+ /*@Doc:
+ virtual destructor.
+ validates the object.
+ */
+
+ virtual int compatibleWith(const Type* aType) const;
+ /*@Doc:
+ to be compatible the following must be true:
+ aType must be MDDBASETYPE or subclass and
+ myBaseType must be compatible with aType->myBaseType
+ */
+
+ virtual int compatibleWithDomain(const r_Minterval* aDomain) const;
+ /*@Doc:
+ create a new MDDDomainType with itself and aDomain, then it
+ checks compatibility with self.
+ */
+
+ virtual r_Bytes getMemorySize() const;
+ /*@Doc:
+ computes memory size by:
+ MDDType::getMemorySize() + myBaseType->getMemorySize() + sizeof(BaseType*);
+ */
+
+ protected:
+
+ virtual void insertInDb() throw (r_Error);
+
+ virtual void readFromDb() throw (r_Error);
+
+ virtual void deleteFromDb() throw (r_Error);
+
+ const BaseType* myBaseType;
+ /*@Doc:
+ reference to the basetype
+ */
+ };
+
+#endif
diff --git a/relcatalogif/mddbasetype.lis b/relcatalogif/mddbasetype.lis
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/relcatalogif/mddbasetype.lis
diff --git a/relcatalogif/mddbasetype.pgc b/relcatalogif/mddbasetype.pgc
new file mode 100644
index 0000000..6b4f11d
--- /dev/null
+++ b/relcatalogif/mddbasetype.pgc
@@ -0,0 +1,125 @@
+/*
+* 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:
+ * Code with embedded SQL for PostgreSQL DBMS
+ *
+ *
+ * COMMENTS:
+ * uses embedded SQL
+ *
+ ************************************************************/
+
+// general embedded SQL related definitions
+EXEC SQL include "../reladminif/sqlglobals.h";
+
+#include "debug-srv.hh"
+#include "mddbasetype.hh"
+#include "raslib/rmdebug.hh"
+#include "reladminif/sqlerror.hh"
+#include "reladminif/externs.h"
+#include "reladminif/objectbroker.hh"
+
+void
+MDDBaseType::insertInDb() throw (r_Error)
+{
+ RMDBGENTER(6, RMDebug::module_catalogif, "MDDBaseType", "insertInDb() " << myOId << " " << getTypeName());
+ EXEC SQL BEGIN DECLARE SECTION;
+ long mddtypeid;
+ double mddbasetypeid;
+ char mddtypename[STRING_MAXLEN];
+ EXEC SQL END DECLARE SECTION;
+
+ (void) strncpy( mddtypename, (char*) getName(), (size_t) sizeof(mddtypename) );
+ DBObject* obj = (DBObject*)getBaseType();
+ mddbasetypeid = obj->getOId();
+ mddtypeid = myOId.getCounter();
+ TALK( "EXEC SQL INSERT INTO RAS_MDDBASETYPES ( MDDBaseTypeOId, MDDTypeName, BaseTypeId)"
+ << " VALUES ( " << mddtypeid << ", " << mddtypename << ", " << mddbasetypeid << ")" );
+ EXEC SQL INSERT INTO RAS_MDDBASETYPES ( MDDBaseTypeOId, MDDTypeName, BaseTypeId)
+ VALUES ( :mddtypeid, :mddtypename, :mddbasetypeid);
+ if (check("MDDBaseType::insertInDb()\0"))
+ generateException();
+ DBObject::insertInDb();
+ RMDBGEXIT(5, RMDebug::module_catalogif, "MDDBaseType", "insertInDb() " << myOId);
+}
+
+void
+MDDBaseType::readFromDb() throw (r_Error)
+{
+ RMDBGENTER(5, RMDebug::module_catalogif, "MDDBaseType", "readFromDb() " << myOId);
+#ifdef RMANBENCHMARK
+ DBObject::readTimer.resume();
+#endif
+ EXEC SQL BEGIN DECLARE SECTION;
+ long mddtypeid1;
+ char mddtypename1[STRING_MAXLEN];
+ double mddbasetypeid1;
+ EXEC SQL END DECLARE SECTION;
+
+ mddtypeid1 = myOId.getCounter();
+ mddbasetypeid1 = 0;
+
+ TALK( "EXEC SQL SELECT BaseTypeId, MDDTypeName INTO :mddbasetypeid1, :mddtypename1 "
+ << "FROM RAS_MDDBASETYPES "
+ << "WHERE MDDBaseTypeOId = " << mddtypeid1 );
+ EXEC SQL SELECT BaseTypeId, MDDTypeName INTO :mddbasetypeid1, :mddtypename1
+ FROM RAS_MDDBASETYPES
+ WHERE MDDBaseTypeOId = :mddtypeid1;
+ if (check("MDDBaseType::readFromDb() SELECT FROM RAS_MDDBASETYPES\0") != 0)
+ if (SQLCODE == 100)
+ throw r_Error(r_Error::r_Error_ObjectUnknown);
+ else
+ generateException();
+
+ setName(mddtypename1);
+ myBaseType = (BaseType*)ObjectBroker::getObjectByOId(OId(mddbasetypeid1));
+#ifdef RMANBENCHMARK
+ DBObject::readTimer.pause();
+#endif
+ DBObject::readFromDb();
+ RMDBGEXIT(5, RMDebug::module_catalogif, "MDDBaseType", "readFromDb() " << myOId);
+}
+
+void
+MDDBaseType::deleteFromDb() throw (r_Error)
+{
+ RMDBGENTER(5, RMDebug::module_catalogif, "MDDBaseType", "deleteFromDb() " << myOId << " " << getTypeName());
+ EXEC SQL BEGIN DECLARE SECTION;
+ long mddtypeid2;
+ EXEC SQL END DECLARE SECTION;
+
+ mddtypeid2 = myOId.getCounter();
+
+ TALK( "EXEC SQL DELETE FROM RAS_MDDBASETYPES WHERE MDDBaseTypeOId = " << mddtypeid2 );
+ EXEC SQL DELETE FROM RAS_MDDBASETYPES
+ WHERE MDDBaseTypeOId = :mddtypeid2;
+ if (check("MDDBaseType::deleteFromDb()\0"))
+ generateException();
+ DBObject::deleteFromDb();
+ RMDBGEXIT(5, RMDebug::module_catalogif, "MDDBaseType", "deleteFromDb() " << myOId);
+}
+
diff --git a/relcatalogif/mddbasetypecommon.cc b/relcatalogif/mddbasetypecommon.cc
new file mode 100644
index 0000000..036abe8
--- /dev/null
+++ b/relcatalogif/mddbasetypecommon.cc
@@ -0,0 +1,174 @@
+#include "mymalloc/mymalloc.h"
+/*
+* 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:
+ * code common to all database interface implementations
+ *
+ * CHANGE HISTORY (append further entries):
+ */
+
+#include <malloc.h>
+#include "raslib/rmdebug.hh"
+#include "mddbasetype.hh"
+#include "mdddomaintype.hh"
+#include "basetype.hh"
+#include <iostream>
+#include "reladminif/sqlerror.hh"
+#include "reladminif/externs.h"
+#include "reladminif/objectbroker.hh"
+#include <cstring>
+
+r_Bytes
+MDDBaseType::getMemorySize() const
+ {
+ return MDDType::getMemorySize() + myBaseType->getMemorySize() + sizeof(BaseType*);
+ }
+
+MDDBaseType::MDDBaseType(const OId& id) throw (r_Error)
+ : MDDType(id)
+ {
+ RMDBGENTER(5, RMDebug::module_catalogif, "MDDBaseType", "MDDBaseType(" << myOId << ")");
+ if (objecttype == OId::MDDBASETYPEOID)
+ {
+ mySubclass = MDDBASETYPE;
+ readFromDb();
+ }
+ RMDBGEXIT(5, RMDebug::module_catalogif, "MDDBaseType", "MDDBaseType(" << myOId << ")");
+ }
+
+MDDBaseType::MDDBaseType(const char* newTypeName, const BaseType* newBaseType)
+ : MDDType(newTypeName)
+ {
+ objecttype = OId::MDDBASETYPEOID;
+ myBaseType = newBaseType;
+ mySubclass = MDDBASETYPE;
+ }
+
+MDDBaseType::MDDBaseType()
+ : MDDType("unnamed mddbasetype")
+ {
+ objecttype = OId::MDDBASETYPEOID;
+ myBaseType = 0;
+ mySubclass = MDDBASETYPE;
+ }
+
+MDDBaseType::MDDBaseType(const char* tname)
+ : MDDType(tname)
+ {
+ objecttype = OId::MDDBASETYPEOID;
+ myBaseType = 0;
+ mySubclass = MDDBASETYPE;
+ }
+
+MDDBaseType::MDDBaseType(const MDDBaseType& old)
+ : MDDType(old)
+ {
+ myBaseType = old.myBaseType;
+ }
+
+MDDBaseType& MDDBaseType::operator=(const MDDBaseType& old)
+ {
+ // Gracefully handle self assignment
+ if (this == &old)
+ return *this;
+ MDDType::operator=(old);
+ myBaseType = old.myBaseType;
+ return *this;
+ }
+
+char*
+MDDBaseType::getTypeStructure() const
+ {
+ char* baseType = myBaseType->getTypeStructure();
+ char* result = (char*)mymalloc(10 + strlen(baseType));
+
+ strcpy(result, "marray <");
+ strcat(result, baseType);
+ strcat(result, ">");
+
+ free(baseType);
+ return result;
+ }
+
+void
+MDDBaseType::print_status( ostream& s ) const
+ {
+ s << "\tr_Marray" << "<" << myBaseType->getTypeName() << "\t>";
+ }
+
+const BaseType*
+MDDBaseType::getBaseType() const
+ {
+ return myBaseType;
+ }
+
+MDDBaseType::~MDDBaseType()
+ {
+ RMDBGENTER(5, RMDebug::module_catalogif, "MDDBaseType", "~MDDBaseType() " << myOId);
+ validate();
+ RMDBGEXIT(5, RMDebug::module_catalogif, "MDDBaseType", "~MDDBaseType() " << myOId);
+ }
+
+int
+MDDBaseType::compatibleWith(const Type* aType) const
+ {
+ RMDBGENTER(11, RMDebug::module_catalogif, "MDDBaseType", "compatibleWith(" << aType->getName() << ") " << getName());
+ int retval;
+ if( ((MDDType*)aType)->getSubtype() != MDDBASETYPE && ((MDDType*)aType)->getSubtype() != MDDDOMAINTYPE && ((MDDType*)aType)->getSubtype() != MDDDIMENSIONTYPE )
+ {
+ RMDBGMIDDLE(11, RMDebug::module_catalogif, "MDDBaseType", "not mddbasetype or subclass");
+ retval = 0;
+ }
+ else {
+ // myBaseType has to be specified
+ if( myBaseType->compatibleWith(((MDDBaseType*)aType)->getBaseType()) )
+ {
+ retval = 1;
+ }
+ else {
+ RMDBGMIDDLE(11, RMDebug::module_catalogif, "MDDBaseType", "basetypes not compatible");
+ retval = 0;
+ }
+ }
+ RMDBGEXIT(11, RMDebug::module_catalogif, "MDDBaseType", "compatibleWith(" << aType->getName() << ") " << getName() << " retval " << retval);
+ return retval;
+ }
+
+int
+MDDBaseType::compatibleWithDomain(const r_Minterval* aDomain ) const
+ {
+ RMDBGENTER(11, RMDebug::module_catalogif, "MDDBaseType", "compatibleWithDomain(" << *aDomain << ") " << getName());
+ int retval;
+
+ // create an MDDDomainType with aDomain and myBaseType
+ MDDDomainType tempType( "tempType", myBaseType, *aDomain );
+ // use normal compatibleWith
+ retval = this->compatibleWith( &tempType );
+ RMDBGEXIT(11, RMDebug::module_catalogif, "MDDBaseType", "compatibleWithDomain(" << aDomain << ") " << getName() << " retval " << retval);
+ return retval;
+ }
+
diff --git a/relcatalogif/mdddimensiontype.hh b/relcatalogif/mdddimensiontype.hh
new file mode 100644
index 0000000..293812d
--- /dev/null
+++ b/relcatalogif/mdddimensiontype.hh
@@ -0,0 +1,128 @@
+/*
+* 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>.
+*/
+// -*-C++-*- (for Emacs)
+
+/*************************************************************
+ *
+ *
+ * PURPOSE:
+ * The MDDBaseType class is used as a type for MDDs where
+ * the base type and the dimensionality is specified.
+ *
+ *
+ * COMMENTS:
+ *
+ ************************************************************/
+
+#ifndef _MDDDIMENSIONTYPE_HH_
+#define _MDDDIMENSIONTYPE_HH_
+
+#include <iostream>
+#include "raslib/mddtypes.hh"
+#include "catalogmgr/ops.hh"
+#include "mddbasetype.hh"
+
+class OId;
+
+//@ManMemo: Module: {\bf relcatalogif}.
+
+/*@Doc:
+ The MDDBaseType class is used as a type for MDDs where
+ the base type and the dimensionality is specified.
+*/
+
+class MDDDimensionType : public MDDBaseType
+ {
+ public:
+ virtual char* getTypeStructure() const;
+ /*@Doc:
+ */
+
+ virtual r_Bytes getMemorySize() const;
+ /*@Doc:
+ the memory size is computed by:
+ MDDBaseType::getMemorySize() + sizeof(r_Dimension);
+ */
+
+ MDDDimensionType(const OId& id) throw (r_Error);
+ /*@Doc:
+ */
+
+ MDDDimensionType(const char* newTypeName, const BaseType* newBaseType, r_Dimension newDimension);
+ /*@Doc:
+ constructor.
+ */
+
+ MDDDimensionType();
+ /*@Doc:
+ default constructor, cannot be used.
+ */
+
+ MDDDimensionType(const MDDDimensionType& old);
+ /*@Doc:
+ copy constructor.
+ */
+
+ MDDDimensionType& operator=(const MDDDimensionType& old);
+ /*@Doc:
+ assignment operator.
+ */
+
+ virtual void print_status( ostream& s ) const;
+ /*@Doc:
+ writes the state of the object to the specified stream
+ */
+
+ r_Dimension getDimension() const;
+ /*@Doc:
+ return dimensionality
+ */
+
+ virtual ~MDDDimensionType();
+ /*@Doc:
+ virtual destructor.
+ */
+
+ virtual int compatibleWith(const Type* aType) const;
+ /*@Doc:
+ is compatible if:
+ aType is MDDDimType or MDDDomType and
+ the basetypes are compatible
+ and dimensionality is the same
+ */
+
+ protected:
+
+ virtual void insertInDb() throw (r_Error);
+
+ virtual void readFromDb() throw (r_Error);
+
+ virtual void deleteFromDb() throw (r_Error);
+
+ r_Dimension myDimension;
+ /*@Doc:
+ dimensionality.
+ */
+ };
+
+#endif
diff --git a/relcatalogif/mdddimensiontype.lis b/relcatalogif/mdddimensiontype.lis
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/relcatalogif/mdddimensiontype.lis
diff --git a/relcatalogif/mdddimensiontype.pgc b/relcatalogif/mdddimensiontype.pgc
new file mode 100644
index 0000000..c8b631c
--- /dev/null
+++ b/relcatalogif/mdddimensiontype.pgc
@@ -0,0 +1,148 @@
+#include "mymalloc/mymalloc.h"
+// This is -*- C++ -*-
+
+/*
+* 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>.
+*/
+/*************************************************************************
+ *
+ *
+ * PURPOSE:
+ * Code with embedded SQL for PostgreSQL DBMS
+ *
+ *
+ * COMMENTS:
+ * none
+ *
+ ***********************************************************************/
+
+// general embedded SQL related definitions
+EXEC SQL include "../reladminif/sqlglobals.h";
+
+#include "mdddimensiontype.hh"
+#include "raslib/rmdebug.hh"
+#include "reladminif/objectbroker.hh"
+#include "reladminif/sqlerror.hh"
+
+void
+MDDDimensionType::insertInDb() throw (r_Error)
+{
+ RMDBGENTER(5, RMDebug::module_catalogif, "MDDDimensionType", "insertInDb() " << myOId << " " << getTypeName());
+ EXEC SQL BEGIN DECLARE SECTION;
+ long mddtypeid;
+ short dimension;
+ double mddbasetypeid;
+ char mddtypename[STRING_MAXLEN];
+ EXEC SQL END DECLARE SECTION;
+
+ dimension = myDimension;
+ mddtypeid = myOId.getCounter();
+ (void) strncpy( mddtypename, (char*) getName(), (size_t) sizeof(mddtypename) );
+ DBObject* obj = (DBObject*)getBaseType();
+ mddbasetypeid = obj->getOId();
+ RMDBGMIDDLE(5, RMDebug::module_catalogif, "MDDDimensionType", " typeid " << mddtypeid << " name " << mddtypename << " basetypeoid " << mddbasetypeid << "dimension " << dimension)
+
+ EXEC SQL INSERT INTO RAS_MDDDIMTYPES (
+ MDDDimTypeOId,
+ MDDTypeName,
+ BaseTypeId,
+ Dimension
+ )
+ VALUES (
+ :mddtypeid,
+ :mddtypename,
+ :mddbasetypeid,
+ :dimension
+ );
+ if (check("MDDDimensionType::insertInDb()\0"))
+ generateException();
+ DBObject::insertInDb();
+ RMDBGEXIT(5, RMDebug::module_catalogif, "MDDDimensionType", "insertInDb() " << myOId);
+}
+
+void
+MDDDimensionType::readFromDb() throw (r_Error)
+{
+ RMDBGENTER(5, RMDebug::module_catalogif, "MDDDimensionType", "readFromDb() " << myOId);
+#ifdef RMANBENCHMARK
+ DBObject::readTimer.resume();
+#endif
+ EXEC SQL BEGIN DECLARE SECTION;
+ long mddtypeid1;
+ char mddtypename1[STRING_MAXLEN];
+ double mddbasetypeid1;
+ short dimension1;
+ EXEC SQL END DECLARE SECTION;
+
+ mddtypeid1 = myOId.getCounter();
+ mddbasetypeid1 = 0;
+ dimension1 = 0;
+
+ EXEC SQL SELECT
+ Dimension,
+ BaseTypeId,
+ MDDTypeName
+ INTO
+ :dimension1,
+ :mddbasetypeid1,
+ :mddtypename1
+ FROM
+ RAS_MDDDIMTYPES
+ WHERE
+ MDDDimTypeOId = :mddtypeid1;
+ if (check("MDDDimensionType::MDDDimensionType() SELECT FROM RAS_MDDDIMTYPES\0") != 0)
+ if (SQLCODE == 100)
+ throw r_Error(r_Error::r_Error_ObjectUnknown);
+ else
+ generateException();
+
+ myDimension = dimension1;
+ setName(mddtypename1);
+ myBaseType = (BaseType*)ObjectBroker::getObjectByOId(OId(mddbasetypeid1));
+#ifdef RMANBENCHMARK
+ DBObject::readTimer.pause();
+#endif
+ RMDBGMIDDLE(6, RMDebug::module_catalogif, "MDDDimensionType", "myBaseType at " << myBaseType);
+ DBObject::readFromDb();
+ RMDBGEXIT(5, RMDebug::module_catalogif, "MDDDimensionType", "readFromDb() " << myOId);
+}
+
+void
+MDDDimensionType::deleteFromDb() throw (r_Error)
+{
+ RMDBGENTER(5, RMDebug::module_catalogif, "MDDDimensionType", "deleteFromDb() " << myOId << " " << getTypeName());
+ EXEC SQL BEGIN DECLARE SECTION;
+ long mddtypeid3;
+ EXEC SQL END DECLARE SECTION;
+
+ mddtypeid3 = myOId.getCounter();
+
+ EXEC SQL DELETE FROM
+ RAS_MDDDIMTYPES
+ WHERE
+ MDDDimTypeOId = :mddtypeid3;
+ if (check("MDDDimensionType::deleteFromDb()\0"))
+ generateException();
+ DBObject::deleteFromDb();
+ RMDBGEXIT(5, RMDebug::module_catalogif, "MDDDimensionType", "deleteFromDb() " << myOId);
+}
+
diff --git a/relcatalogif/mdddimensiontypecommon.cc b/relcatalogif/mdddimensiontypecommon.cc
new file mode 100644
index 0000000..dc71b06
--- /dev/null
+++ b/relcatalogif/mdddimensiontypecommon.cc
@@ -0,0 +1,166 @@
+/*
+* 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>.
+*/
+#include "mymalloc/mymalloc.h"
+#include "raslib/rmdebug.hh"
+#include "mdddimensiontype.hh"
+#include <malloc.h>
+#include "basetype.hh"
+#include "mdddomaintype.hh"
+#include <iostream>
+#include "reladminif/sqlerror.hh"
+#include "reladminif/externs.h"
+#include "reladminif/objectbroker.hh"
+#include <stdio.h>
+#include <cstring>
+
+r_Bytes
+MDDDimensionType::getMemorySize() const
+ {
+ return MDDBaseType::getMemorySize() + sizeof(r_Dimension);
+ }
+
+MDDDimensionType::MDDDimensionType(const OId& id) throw (r_Error)
+ : MDDBaseType(id),
+ myDimension(0)
+ {
+ RMDBGENTER(4, RMDebug::module_catalogif, "MDDDimensionType", "MDDDimensionType(" << myOId << ")");
+ if (objecttype == OId::MDDDIMTYPEOID)
+ {
+ mySubclass = MDDDIMENSIONTYPE;
+ readFromDb();
+ }
+ RMDBGEXIT(4, RMDebug::module_catalogif, "MDDDimensionType", "MDDDimensionType(" << myOId << ")");
+ }
+
+MDDDimensionType::MDDDimensionType(const char* newTypeName, const BaseType* newBaseType, r_Dimension newDimension)
+ : MDDBaseType(newTypeName, newBaseType),
+ myDimension(newDimension)
+ {
+ objecttype = OId::MDDDIMTYPEOID;
+ mySubclass = MDDDIMENSIONTYPE;
+ }
+
+MDDDimensionType::MDDDimensionType()
+ : MDDBaseType("unnamed mdddimensiontype"),
+ myDimension(0)
+ {
+ objecttype = OId::MDDDIMTYPEOID;
+ mySubclass = MDDDIMENSIONTYPE;
+ }
+
+MDDDimensionType::MDDDimensionType(const MDDDimensionType& old)
+ : MDDBaseType(old)
+ {
+ objecttype = OId::MDDDIMTYPEOID;
+ myDimension = old.myDimension;
+ }
+
+MDDDimensionType&
+MDDDimensionType::operator=(const MDDDimensionType& old)
+ {
+ // Gracefully handle self assignment
+ if (this == &old)
+ return *this;
+ MDDBaseType::operator=(old);
+ myDimension = old.myDimension;
+ return *this;
+ }
+
+char*
+MDDDimensionType::getTypeStructure() const
+ {
+ char dimBuf[255];
+ sprintf(dimBuf, "%d", myDimension);
+ RMDBGENTER(10, RMDebug::module_catalogif, "MDDDimensionType", "getTypeStructure()");
+ RMDBGMIDDLE(10, RMDebug::module_catalogif, "MDDDimensionType", "myBaseType at " << myBaseType);
+ char* baseType = myBaseType->getTypeStructure();
+ RMDBGMIDDLE(10, RMDebug::module_catalogif, "MDDDimensionType", "basetype at " << baseType);
+ char* result = (char*)mymalloc(12 + strlen(baseType) + strlen(dimBuf));
+
+ strcpy(result, "marray <");
+ strcat(result, baseType);
+ strcat(result, ", ");
+ strcat(result, dimBuf);
+ strcat(result, ">");
+
+ free(baseType);
+ RMDBGEXIT(10, RMDebug::module_catalogif, "MDDDimensionType", "getTypeStructure() " << result);
+ return result;
+ }
+
+void
+MDDDimensionType::print_status( ostream& s ) const
+ {
+ s << "\tr_Marray" << "<" << myBaseType->getTypeName() << "\t, " << myDimension << ">";
+ }
+
+r_Dimension
+MDDDimensionType::getDimension() const
+ {
+ return myDimension;
+ }
+
+MDDDimensionType::~MDDDimensionType()
+ {
+ RMDBGENTER(4, RMDebug::module_catalogif, "MDDDimensionType", "~MDDDimensionType() " << myOId);
+ validate();
+ RMDBGEXIT(4, RMDebug::module_catalogif, "MDDDimensionType", "~MDDDimensionType() " << myOId);
+ }
+
+int
+MDDDimensionType::compatibleWith(const Type* aType) const
+ {
+ RMDBGENTER(5, RMDebug::module_catalogif, "MDDDimensionType", "compatibleWith(" << aType->getName() << ") " << getName());
+ int retval;
+ if( ((MDDType*)aType)->getSubtype() != MDDDOMAINTYPE && ((MDDType*)aType)->getSubtype() != MDDDIMENSIONTYPE )
+ {
+ RMDBGMIDDLE(6, RMDebug::module_catalogif, "MDDDimensionType", "not a domain- or dimensiontype");
+ retval = 0;
+ }
+ else {
+ // check BaseType first
+ if( ! (myBaseType->compatibleWith(((MDDBaseType*)aType)->getBaseType())) )
+ {
+ RMDBGMIDDLE(6, RMDebug::module_catalogif, "MDDDimensionType", "basetypes are not compatible");
+ retval = 0;
+ }
+ else {
+ // check dimensionality
+ if( ((MDDType*)aType)->getSubtype() == MDDDIMENSIONTYPE )
+ {
+ RMDBGMIDDLE(6, RMDebug::module_catalogif, "MDDDimensionType", "check for dimension equality");
+ retval = (myDimension == ((MDDDimensionType*)aType)->getDimension());
+ }
+ else {
+ if( ((MDDType*)aType)->getSubtype() == MDDDOMAINTYPE )
+ {
+ RMDBGMIDDLE(6, RMDebug::module_catalogif, "MDDDimensionType", "check for dimension equality");
+ retval = ( ((MDDDimensionType*)this)->myDimension == ((MDDDomainType*)aType)->getDomain()->dimension() );
+ }
+ }
+ }
+ }
+ RMDBGEXIT(5, RMDebug::module_catalogif, "MDDDimensionType", "compatibleWith(" << aType->getName() << ") " << getName() << " " << retval);
+ return retval;
+ }
+
diff --git a/relcatalogif/mdddomaintype.hh b/relcatalogif/mdddomaintype.hh
new file mode 100644
index 0000000..22d5352
--- /dev/null
+++ b/relcatalogif/mdddomaintype.hh
@@ -0,0 +1,137 @@
+// -*-C++-*- (for Emacs)
+
+/*
+* 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>.
+*/
+/*************************************************************
+ *
+ *
+ * PURPOSE:
+ * The MDDBaseType class is used as a type for MDDs where
+ * the base type and the domain is specified.
+ *
+ *
+ * COMMENTS:
+ *
+ ************************************************************/
+
+#ifndef _MDDDOMAINTYPE_HH_
+#define _MDDDOMAINTYPE_HH_
+
+class MDDDomainType;
+
+#include <iostream>
+#include "raslib/minterval.hh"
+#include "catalogmgr/ops.hh"
+#include "mddbasetype.hh"
+#include "raslib/mddtypes.hh" //for r_Range
+
+class DBMinterval;
+class OId;
+
+//@ManMemo: Module: {\bf relcatalogif}.
+
+/*@Doc:
+ The MDDBaseType class is used as a type for MDDs where
+ the base type and the domain is specified.
+*/
+
+class MDDDomainType : public MDDBaseType
+ {
+ public:
+ virtual char* getTypeStructure() const;
+ /*@Doc:
+ looks like:
+ marray <myBaseType->getTypeStructure(), myDomain->get_string_representation()>
+ */
+
+ MDDDomainType(const OId& id) throw (r_Error);
+
+ MDDDomainType(const char* newTypeName, const BaseType* newBaseType, const r_Minterval& newDomain);
+
+ MDDDomainType();
+ /*@Doc:
+ default constructor, cannot be used.
+ */
+
+ MDDDomainType(const MDDDomainType& old);
+ /*@Doc:
+ copy constructor.
+ */
+
+ MDDDomainType& operator=(const MDDDomainType& old);
+ /*@Doc:
+ assignment operator.
+ */
+
+ const r_Minterval* getDomain() const;
+ /*@Doc:
+ returns domain.
+ */
+
+ virtual void print_status( ostream& s ) const;
+ /*@Doc:
+ writes the state of the object to the specified stream.
+ looks like: \tr_Marray<myBaseType->getTypeName(), myDomain->print_status()\t>
+ */
+
+ virtual ~MDDDomainType();
+ /*@Doc:
+ virtual destructor.
+ calls validate and deletes myDomain
+ */
+
+ virtual void setPersistent(bool t) throw (r_Error);
+ /*@Doc:
+ this method from DBObject is overridden to make sure that
+ the dbminterval is also made persistent/deleted from db.
+ */
+
+ virtual int compatibleWith(const Type* aType) const;
+ /*@Doc:
+ aType is compatible if:
+ aType is a MDDDomainType and
+ the basetypes are compatible
+ */
+
+ virtual r_Bytes getMemorySize() const;
+ /*@Doc:
+ memory space is computed by
+ MDDBaseType::getMemorySize() + sizeof(DBMinterval*)
+ + myDomain->getMemorySize();
+ */
+
+ protected:
+
+ DBMinterval* myDomain;
+ /*@Doc:
+ persistent domain.
+ */
+
+ virtual void insertInDb() throw (r_Error);
+
+ virtual void readFromDb() throw (r_Error);
+
+ virtual void deleteFromDb() throw (r_Error);
+ };
+
+#endif
diff --git a/relcatalogif/mdddomaintype.lis b/relcatalogif/mdddomaintype.lis
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/relcatalogif/mdddomaintype.lis
diff --git a/relcatalogif/mdddomaintype.pgc b/relcatalogif/mdddomaintype.pgc
new file mode 100644
index 0000000..ec2cd80
--- /dev/null
+++ b/relcatalogif/mdddomaintype.pgc
@@ -0,0 +1,143 @@
+#include "mymalloc/mymalloc.h"
+// This is -*- C++ -*-
+
+/*
+* 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>.
+*/
+/*************************************************************
+ *
+ *
+ * PURPOSE:
+ * Code with embedded SQL for PostgreSQL DBMS
+ *
+ *
+ * COMMENTS:
+ * uses embedded SQL
+ *
+ ************************************************************/
+
+// general embedded SQL related definitions
+EXEC SQL include "../reladminif/sqlglobals.h";
+
+#include "mdddomaintype.hh"
+#include "raslib/rmdebug.hh"
+#include "reladminif/objectbroker.hh"
+#include "reladminif/sqlerror.hh"
+#include "dbminterval.hh"
+
+
+void
+MDDDomainType::insertInDb() throw (r_Error)
+{
+ RMDBGENTER(5, RMDebug::module_catalogif, "MDDDomainType", "insertInDb() " << myOId << " " << getTypeName());
+
+ char* domstr = 0;
+ EXEC SQL BEGIN DECLARE SECTION;
+ long mddtypeid;
+ double mddbasetypeid;
+ char mddtypename[VARCHAR_MAXLEN];
+ long domainid;
+ EXEC SQL END DECLARE SECTION;
+
+ (void) strncpy( mddtypename, (char*) getName(), (size_t) sizeof(mddtypename) );
+ DBObject* obj = (DBObject*)getBaseType();
+ mddbasetypeid = obj->getOId();
+ mddtypeid = myOId.getCounter();
+ domainid = myDomain->getOId().getCounter();
+
+ EXEC SQL INSERT INTO RAS_MDDDOMTYPES ( MDDDomTypeOId, MDDTypeName, BaseTypeId, DomainId)
+ VALUES ( :mddtypeid, :mddtypename, :mddbasetypeid, :domainid);
+ if (check("MDDDomainType::insertInDb()\0"))
+ generateException();
+
+ DBObject::insertInDb();
+
+ RMDBGEXIT(5, RMDebug::module_catalogif, "MDDDomainType", "insertInDb() " << myOId);
+}
+
+void
+MDDDomainType::readFromDb() throw (r_Error)
+{
+ RMDBGENTER(5, RMDebug::module_catalogif, "MDDDomainType", "readFromDb() " << myOId);
+
+ EXEC SQL BEGIN DECLARE SECTION;
+ long mddtypeid1;
+ struct {
+ short length;
+ char data[STRING_MAXLEN];
+ } mddtypename1;
+ double mddbasetypeid1;
+ long domainid1;
+ EXEC SQL END DECLARE SECTION;
+
+ mddtypeid1 = myOId.getCounter();
+ mddbasetypeid1 = 0;
+
+ EXEC SQL SELECT BaseTypeId, MDDTypeName, DomainId
+ INTO :mddbasetypeid1, :mddtypename1, :domainid1
+ FROM RAS_MDDDOMTYPES
+ WHERE MDDDomTypeOId = :mddtypeid1;
+ if (check("MDDDomainType::MDDDomainType() SELECT FROM RAS_MDDDOMTYPES\0") != 0)
+ {
+ if (SQLCODE == 100)
+ throw r_Error(r_Error::r_Error_ObjectUnknown);
+ else
+ generateException();
+ }
+
+ setName(mddtypename1.length, mddtypename1.data);
+ myBaseType = (BaseType*)ObjectBroker::getObjectByOId(OId(mddbasetypeid1));
+ myDomain = (DBMinterval*)ObjectBroker::getObjectByOId(OId(domainid1, OId::DBMINTERVALOID));
+ myDomain->setCached(true);
+
+#ifdef RMANBENCHMARK
+ DBObject::readTimer.pause();
+#endif
+
+ DBObject::readFromDb();
+
+ RMDBGEXIT(5, RMDebug::module_catalogif, "MDDDomainType", "readFromDb() " << myOId);
+}
+
+void
+MDDDomainType::deleteFromDb() throw (r_Error)
+{
+ RMDBGENTER(5, RMDebug::module_catalogif, "MDDDomainType", "deleteFromDb() " << myOId << " " << getTypeName());
+
+ EXEC SQL BEGIN DECLARE SECTION;
+ long mddtypeid2;
+ EXEC SQL END DECLARE SECTION;
+
+ mddtypeid2 = myOId.getCounter();
+
+ EXEC SQL DELETE FROM RAS_MDDDOMTYPES
+ WHERE MDDDomTypeOId = :mddtypeid2;
+ if (check("MDDDomainType::deleteFromDb()\0"))
+ generateException();
+
+ myDomain->setPersistent(false);
+ myDomain->setCached(false);
+
+ DBObject::deleteFromDb();
+
+ RMDBGEXIT(5, RMDebug::module_catalogif, "MDDDomainType", "deleteFromDb() " << myOId);
+}
diff --git a/relcatalogif/mdddomaintypecommon.cc b/relcatalogif/mdddomaintypecommon.cc
new file mode 100644
index 0000000..0f64848
--- /dev/null
+++ b/relcatalogif/mdddomaintypecommon.cc
@@ -0,0 +1,204 @@
+/*
+* 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>.
+*/
+#include "mymalloc/mymalloc.h"
+#include "raslib/rmdebug.hh"
+#include "mdddomaintype.hh"
+#include "mdddimensiontype.hh"
+#include "malloc.h"
+#include "basetype.hh"
+#include <iostream>
+#include "reladminif/sqlerror.hh"
+#include "reladminif/externs.h"
+#include "reladminif/objectbroker.hh"
+#include "dbminterval.hh"
+#include <cstring>
+
+r_Bytes
+MDDDomainType::getMemorySize() const
+ {
+ return MDDBaseType::getMemorySize() + sizeof(DBMinterval*) + myDomain->getMemorySize();
+ }
+
+MDDDomainType::MDDDomainType(const OId& id) throw (r_Error)
+ : MDDBaseType(id),
+ myDomain(0)
+ {
+ RMDBGENTER(4, RMDebug::module_catalogif, "MDDDomainType", "MDDDomainType(" << id <<")");
+ if (objecttype == OId::MDDDOMTYPEOID)
+ {
+ mySubclass = MDDDOMAINTYPE;
+ readFromDb();
+ }
+ RMDBGMIDDLE(8, RMDebug::module_catalogif, "MDDDomainType", "Domain\t:" << *myDomain);
+ RMDBGEXIT(4, RMDebug::module_catalogif, "MDDDomainType", "MDDDomainType(" << id <<")");
+ }
+
+MDDDomainType::MDDDomainType(const char* newTypeName, const BaseType* newBaseType, const r_Minterval& newDomain)
+ : MDDBaseType(newTypeName, newBaseType)
+ {
+ objecttype = OId::MDDDOMTYPEOID;
+ myDomain = new DBMinterval(newDomain);
+ myDomain->setCached(true);
+ mySubclass = MDDDOMAINTYPE;
+ }
+
+MDDDomainType::MDDDomainType()
+ : MDDBaseType("unnamed mdddomaintype"),
+ myDomain(0)
+ {
+ objecttype = OId::MDDDOMTYPEOID;
+ mySubclass = MDDDOMAINTYPE;
+ }
+
+MDDDomainType::MDDDomainType(const MDDDomainType& old)
+ : MDDBaseType(old)
+ {
+ throw r_Error(r_Error::r_Error_FeatureNotSupported);
+ }
+
+MDDDomainType&
+MDDDomainType::operator=(const MDDDomainType& old)
+ {
+ // Gracefully handle self assignment
+ if (this == &old)
+ return *this;
+ MDDBaseType::operator=(old);
+ if (myDomain)
+ {
+ myDomain->setPersistent(false);
+ myDomain->setCached(false);
+ delete myDomain;
+ }
+ myDomain = new DBMinterval(*old.myDomain);
+ myDomain->setCached(true);
+ return *this;
+ }
+
+char*
+MDDDomainType::getTypeStructure() const
+ {
+ char* baseType = myBaseType->getTypeStructure();
+ char* mdom = myDomain->get_string_representation();
+ char* result = (char*)mymalloc(12 + strlen(baseType) + strlen(mdom));
+
+ strcpy(result, "marray <");
+ strcat(result, baseType);
+ strcat(result, ", ");
+ strcat(result, mdom);
+ strcat(result, ">");
+ free(mdom);
+ free(baseType);
+ return result;
+ }
+
+const r_Minterval*
+MDDDomainType::getDomain() const
+ {
+ return myDomain;
+ }
+
+void
+MDDDomainType::print_status( ostream& s ) const
+ {
+ s << "\tr_Marray" << "<" << myBaseType->getTypeName() << ", ";
+ myDomain->print_status(s);
+ s << "\t>";
+ }
+
+MDDDomainType::~MDDDomainType()
+ {
+ RMDBGENTER(4, RMDebug::module_catalogif, "MDDDomainType", "~MDDDomainType() " << myOId << " " << getTypeName());
+
+ validate();
+ if (myDomain)
+ delete myDomain;
+ myDomain = 0;
+ RMDBGEXIT(4, RMDebug::module_catalogif, "MDDDomainType", "~MDDDomainType() " << myOId << " " << getTypeName());
+ }
+
+int
+MDDDomainType::compatibleWith(const Type* aType) const
+ {
+ RMDBGENTER(11, RMDebug::module_catalogif, "MDDDomainType", "compatibleWith(" << aType->getName() << ") " << getName());
+ bool retval = false;
+ if (aType->getType() == MDDTYPE)
+ {
+ MDDTypeEnum ttype = ((const MDDType*)aType)->getSubtype();
+ if (ttype == MDDDOMAINTYPE)
+ {
+ if (myBaseType->compatibleWith(((const MDDBaseType*)aType)->getBaseType()))
+ {
+ if (((const MDDDomainType*)aType)->getDomain()->dimension() == myDomain->dimension())
+ {
+ if (myDomain->covers(*((const MDDDomainType*)aType)->getDomain()))
+ {
+ retval = true;
+ }
+ else {
+ RMDBGMIDDLE(6, RMDebug::module_catalogif, "MDDDomainType", "domain marray types have incompatible domains");
+ }
+ }
+ else {
+ RMDBGMIDDLE(6, RMDebug::module_catalogif, "MDDDomainType", "domain marray types have different dimensions");
+ }
+ }
+ else {
+ RMDBGMIDDLE(6, RMDebug::module_catalogif, "MDDDomainType", "basetypes are not equal");
+ }
+ }
+ else {
+ if (ttype == MDDDIMENSIONTYPE)
+ {
+ if (myBaseType->compatibleWith(((const MDDBaseType*)aType)->getBaseType()))
+ {
+ if (myDomain->dimension() == ((const MDDDimensionType*)aType)->getDimension())
+ {
+ retval = true;
+ }
+ else {
+ RMDBGMIDDLE(6, RMDebug::module_catalogif, "MDDDomainType", "dimension marray type has wrong dimension")
+ }
+ }
+ else {
+ RMDBGMIDDLE(6, RMDebug::module_catalogif, "MDDDomainType", "basetypes are not equal");
+ }
+ }
+ else {
+ RMDBGMIDDLE(6, RMDebug::module_catalogif, "MDDDomainType", "not a dimension/domain type");
+ }
+ }
+ }
+ else {
+ RMInit::logOut << "MDDDomainType::compatibleWith() was passed a type that is not an marray type (" << aType->getName() << endl;
+ }
+ RMDBGEXIT(11, RMDebug::module_catalogif, "MDDDomainType", "compatibleWith(" << aType->getName() << ") " << getName() << " retval " << retval);
+ return retval;
+ }
+
+void
+MDDDomainType::setPersistent(bool t) throw (r_Error)
+ {
+ MDDBaseType::setPersistent(t);
+ myDomain->setPersistent(t);
+ }
+
diff --git a/relcatalogif/mddtype.hh b/relcatalogif/mddtype.hh
new file mode 100644
index 0000000..3508d7a
--- /dev/null
+++ b/relcatalogif/mddtype.hh
@@ -0,0 +1,140 @@
+// -*-C++-*- (for Emacs)
+
+/*
+* 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>.
+*/
+/*************************************************************
+ *
+ *
+ * PURPOSE:
+ * The MDDType class is used as a type for MDDs where nothing
+ * is specified. It also is a superclass for types for MDDs
+ * specifying more.
+ *
+ *
+ * COMMENTS:
+ *
+ ************************************************************/
+
+#ifndef _MDDTYPE_HH_
+#define _MDDTYPE_HH_
+
+#include "catalogmgr/ops.hh"
+#include "type.hh"
+#include "raslib/minterval.hh"
+
+class OId;
+
+//@ManMemo: Module: {\bf relcatalogif}.
+
+/*@Doc:
+ The MDDType class is used as a type for MDDs where nothing
+ is specified. It also is a superclass for types for MDDs
+ specifying more.
+*/
+
+class MDDType : public Type
+ {
+ public:
+ enum MDDTypeEnum { MDDONLYTYPE, MDDBASETYPE, MDDDOMAINTYPE, MDDDIMENSIONTYPE };
+ /*@Doc:
+ enum used for runtime typing.
+ could be superceded by OId::OIdType
+ */
+
+ virtual char* getTypeStructure() const;
+ /*@Doc:
+ returns type as string:
+ marray <>
+ */
+
+ MDDType(const OId& id) throw (r_Error);
+
+ MDDType();
+ /*@Doc:
+ constructor.
+ */
+
+ MDDType(const char* newTypeName);
+ /*@Doc:
+ constructor using type name.
+ */
+
+ MDDType(const MDDType& old);
+ /*@Doc:
+ copy constructor.
+ */
+
+ MDDType& operator=(const MDDType& old);
+ /*@Doc:
+ assignment operator.
+ */
+
+ virtual void print_status( ostream& s ) const;
+ /*@Doc:
+ writes the state of the object to the specified stream:
+ \tr_Marray<>
+ */
+
+ MDDType::MDDTypeEnum getSubtype() const;
+ /*@Doc:
+ return subclass of MDDType (runtime typing)
+ */
+
+ virtual ~MDDType();
+ /*@Doc:
+ virtual destructor.
+ */
+
+ virtual int compatibleWith(const Type* aType) const;
+ /*@Doc:
+ check for compatibility of MDDTypes:
+ if aType is a MDDTYPE Type (don't confuse with MDDType!!)
+ */
+
+ virtual int compatibleWithDomain(const r_Minterval* aDomain) const;
+ /*@Doc:
+ check for compatibility with a certain domain.
+ always returns 1.
+ */
+
+ virtual r_Bytes getMemorySize() const;
+ /*@Doc:
+ the memory space is computed by:
+ sizeof(MDDType::MDDTypeEnum) + DBNamedObject::getMemorySize();
+ */
+
+ protected:
+
+ virtual void insertInDb() throw (r_Error);
+
+ virtual void readFromDb() throw (r_Error);
+
+ virtual void deleteFromDb() throw (r_Error);
+
+ MDDTypeEnum mySubclass;
+ /*@Doc:
+ used for runtime typing and comparison operation.
+ */
+ };
+
+#endif
diff --git a/relcatalogif/mddtype.lis b/relcatalogif/mddtype.lis
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/relcatalogif/mddtype.lis
diff --git a/relcatalogif/mddtype.pgc b/relcatalogif/mddtype.pgc
new file mode 100644
index 0000000..052aba6
--- /dev/null
+++ b/relcatalogif/mddtype.pgc
@@ -0,0 +1,128 @@
+// This is -*- C++ -*-
+
+/*
+* 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>.
+*/
+/*************************************************************
+ *
+ *
+ * PURPOSE:
+ * Code with embedded SQL for PostgreSQL DBMS
+ *
+ *
+ * COMMENTS:
+ * uses embedded SQL
+ *
+ ************************************************************/
+
+
+// general embedded SQL related definitions
+EXEC SQL include "../reladminif/sqlglobals.h";
+
+#include "mddtype.hh"
+#include "raslib/rmdebug.hh"
+#include "reladminif/sqlerror.hh"
+#include "reladminif/externs.h"
+
+
+void
+MDDType::deleteFromDb() throw (r_Error)
+{
+ RMDBGENTER(7, RMDebug::module_catalogif, "MDDType", "deleteFromDb() " << myOId << " " << getTypeName());
+ EXEC SQL BEGIN DECLARE SECTION;
+ long mddtypeid3;
+ EXEC SQL END DECLARE SECTION;
+
+ mddtypeid3 = myOId.getCounter();
+
+ EXEC SQL DELETE FROM RAS_MDDTYPES
+ WHERE RAS_MDDTYPES.MDDTypeOId = :mddtypeid3;
+ if (check("MDDType::deleteFromDb()\0"))
+ generateException();
+
+ DBObject::deleteFromDb();
+
+ RMDBGEXIT(7, RMDebug::module_catalogif, "MDDType", "deleteFromDb() " << myOId);
+}
+
+void
+MDDType::insertInDb() throw (r_Error)
+{
+ RMDBGENTER(7, RMDebug::module_catalogif, "MDDType", "insertInDb() " << myOId << " " << getTypeName());
+ EXEC SQL BEGIN DECLARE SECTION;
+ long mddtypeid;
+ char mddtypename[VARCHAR_MAXLEN];
+ EXEC SQL END DECLARE SECTION;
+
+ mddtypeid = 0;
+ (void) strncpy( mddtypename, (char*) getName(), (size_t) sizeof(mddtypename) );
+ mddtypeid = myOId.getCounter();
+ EXEC SQL INSERT INTO RAS_MDDTYPES ( MDDTypeOId, MDDTypeName)
+ VALUES ( :mddtypeid, :mddtypename);
+ if (check("MDDType::insertInDb()\0"))
+ generateException();
+
+ DBObject::insertInDb();
+
+ RMDBGEXIT(7, RMDebug::module_catalogif, "MDDType", "insertInDb() " << myOId);
+}
+
+void
+MDDType::readFromDb() throw (r_Error)
+{
+ RMDBGENTER(7, RMDebug::module_catalogif, "MDDType", "readFromDb() " << myOId);
+#ifdef RMANBENCHMARK
+ DBObject::readTimer.resume();
+#endif
+ EXEC SQL BEGIN DECLARE SECTION;
+ long mddtypeid1;
+ char mddtypename1[VARCHAR_MAXLEN];
+ EXEC SQL END DECLARE SECTION;
+
+ mddtypeid1 = myOId.getCounter();
+
+ EXEC SQL SELECT
+ MDDTypeName
+ INTO
+ :mddtypename1
+ FROM
+ RAS_MDDTYPES
+ WHERE
+ MDDTypeOId = :mddtypeid1;
+ if (check("MDDType::readFromDb()\0") != 0)
+ {
+ if (SQLCODE == SQLNODATAFOUND) // was: 100 -- PB 2005-feb-13
+ throw r_Error(r_Error::r_Error_ObjectUnknown);
+ else
+ generateException();
+ }
+
+ setName(mddtypename1);
+
+#ifdef RMANBENCHMARK
+ DBObject::readTimer.pause();
+#endif
+
+ DBObject::readFromDb();
+
+ RMDBGEXIT(7, RMDebug::module_catalogif, "MDDType", "readFromDb() " << myOId);
+}
diff --git a/relcatalogif/mddtypecommon.cc b/relcatalogif/mddtypecommon.cc
new file mode 100644
index 0000000..e1ed1dd
--- /dev/null
+++ b/relcatalogif/mddtypecommon.cc
@@ -0,0 +1,128 @@
+/*
+* 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>.
+*/
+#include "mymalloc/mymalloc.h"
+#include <malloc.h>
+#include <iostream>
+#include <string.h>
+#include "raslib/minterval.hh"
+#include "raslib/rmdebug.hh"
+#include "reladminif/sqlerror.hh"
+#include "mddtype.hh"
+#include "reladminif/externs.h"
+
+r_Bytes
+MDDType::getMemorySize() const
+ {
+ return sizeof(MDDType::MDDTypeEnum) + DBNamedObject::getMemorySize();
+ }
+
+MDDType::MDDType(const OId& id) throw (r_Error)
+ : Type(id)
+ {
+ if (objecttype == OId::MDDTYPEOID)
+ {
+ readFromDb();
+ mySubclass = MDDONLYTYPE;
+ }
+ myType = MDDTYPE;
+ }
+
+MDDType::MDDType()
+ : Type("unnamed mddtype")
+ {
+ myType = MDDTYPE;
+ mySubclass = MDDONLYTYPE;
+ objecttype = OId::MDDTYPEOID;
+ }
+
+MDDType::MDDType(const char* newTypeName)
+ : Type(newTypeName)
+ {
+ myType = MDDTYPE;
+ mySubclass = MDDONLYTYPE;
+ objecttype = OId::MDDTYPEOID;
+ }
+
+MDDType::MDDType(const MDDType& old)
+ : Type(old)
+ {
+ myType = old.myType;
+ mySubclass = old.mySubclass;
+ }
+
+MDDType& MDDType::operator=(const MDDType& old)
+ {
+ // Gracefully handle self assignment
+ if (this == &old)
+ return *this;
+ Type::operator=(old);
+ myType = old.myType;
+ mySubclass = old.mySubclass;
+ return *this;
+ }
+
+MDDType::~MDDType()
+ {
+ RMDBGENTER(6, RMDebug::module_catalogif, "MDDType", "~MDDType() " << myOId);
+ validate();
+ RMDBGEXIT(6, RMDebug::module_catalogif, "MDDType", "~MDDType() " << myOId);
+ }
+
+char*
+MDDType::getTypeStructure() const
+ {
+ char* result = (char*)mymalloc(10);
+
+ strcpy(result, "marray <>");
+ return result;
+ }
+
+void
+MDDType::print_status( ostream& s ) const
+ {
+ s << "\tr_Marray" << "<" << ">";
+ }
+
+int
+MDDType::compatibleWith(const Type* aType) const
+ {
+ RMDBGONCE(11, RMDebug::module_catalogif, "MDDType", "compatibleWith(" << aType->getName() << ") " << (aType->getType() != MDDTYPE));
+ if(aType->getType() != MDDTYPE)
+ return 0;
+ else
+ return 1;
+ }
+
+int
+MDDType::compatibleWithDomain(const r_Minterval* aDomain ) const
+ {
+ RMDBGONCE(11, RMDebug::module_catalogif, "MDDType", "compatibleWithDomain(" << *aDomain << ") " << 1);
+ return 1;
+ }
+
+MDDType::MDDTypeEnum
+MDDType::getSubtype() const
+ {
+ return mySubclass;
+ }
+
diff --git a/relcatalogif/octettype.C b/relcatalogif/octettype.C
new file mode 100644
index 0000000..f650574
--- /dev/null
+++ b/relcatalogif/octettype.C
@@ -0,0 +1,158 @@
+/*
+* 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>.
+*/
+/*************************************************************
+ *
+ *
+ * PURPOSE:
+ * uses ODMG-conformant O2 classes
+ *
+ *
+ * COMMENTS:
+ * none
+ *
+ ************************************************************/
+
+static const char rcsid[] = "@(#)catalogif,OctetType: $Header: /home/rasdev/CVS-repository/rasdaman/relcatalogif/octettype.C,v 1.9 2003/12/27 23:23:04 rasdev Exp $";
+
+#include "octettype.hh"
+#include <iomanip>
+#include <string.h>
+#include <limits.h>
+
+OctetType::OctetType(const OId& id)
+ : IntegralType(id)
+ {
+ readFromDb();
+ }
+
+/*************************************************************
+ * Method name...: OctetType();
+ *
+ * Arguments.....: none
+ * Return value..: none
+ * Description...: initializes member variables for an
+ * OctetType.
+ ************************************************************/
+
+OctetType::OctetType()
+ : IntegralType(OctetType::Name, 1)
+ {
+ myType = OCTET;
+ myOId = OId(OCTET, OId::ATOMICTYPEOID);
+ }
+
+/*************************************************************
+ * Method name...: OctetType(const OctetType& old);
+ *
+ * Arguments.....: none
+ * Return value..: none
+ * Description...: copy constructor
+ ************************************************************/
+
+OctetType::OctetType(const OctetType& old)
+ : IntegralType(old)
+ {
+ }
+
+/*************************************************************
+ * Method name...: operator=(const OctetType&);
+ *
+ * Arguments.....: none
+ * Return value..: none
+ * Description...: copy constructor
+ ************************************************************/
+
+OctetType& OctetType::operator=(const OctetType& old)
+ {
+ // Gracefully handle self assignment
+ if (this == &old)
+ return *this;
+ AtomicType::operator=(old);
+ return *this;
+ }
+
+/*************************************************************
+ * Method name...: ~OctetType();
+ *
+ * Arguments.....: none
+ * Return value..: none
+ * Description...: virtual destructor
+ ************************************************************/
+
+OctetType::~OctetType()
+{
+}
+
+/*************************************************************
+ * Method name...: void printCell( ostream& stream,
+ * const char* cell )
+ *
+ * Arguments.....:
+ * stream: stream to print on
+ * cell: pointer to cell to print
+ * Return value..: none
+ * Description...: prints a cell cell in hex on stream
+ * followed by a space.
+ * Assumes that Octet is stored MSB..LSB
+ * on HP.
+ ************************************************************/
+
+void
+OctetType::printCell( ostream& stream, const char* cell ) const
+{
+ // !!!! HP specific, assumes 1 Byte char
+ stream << std::setw(4) << (r_Long)(*(char*)cell);
+}
+
+r_Long*
+OctetType::convertToCLong(const char* cell, r_Long* value) const
+{
+ // !!!! HP specific, assumes 4 Byte long and MSB..LSB
+ // byte order
+ *value = *(char*)cell;
+ return value;
+}
+
+
+char*
+OctetType::makeFromCLong(char* cell, const r_Long* value) const
+{
+ r_Long myLong = *value;
+ // restricting long to value range of short
+ myLong = myLong > SCHAR_MAX ? SCHAR_MAX : myLong;
+ myLong = myLong < SCHAR_MIN ? SCHAR_MIN : myLong;
+ // !!!! HP specific, assumes 4 Byte long and MSB..LSB
+ // byte order
+ *(char*)(cell) = (char)myLong;
+ return cell;
+}
+
+void
+OctetType::readFromDb() throw (r_Error)
+ {
+ setName(OctetType::Name);
+ size = 1;
+ myType = OCTET;
+ myOId = OId(OCTET, OId::ATOMICTYPEOID);
+ }
+
diff --git a/relcatalogif/octettype.hh b/relcatalogif/octettype.hh
new file mode 100644
index 0000000..8a5107c
--- /dev/null
+++ b/relcatalogif/octettype.hh
@@ -0,0 +1,103 @@
+/*
+* 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>.
+*/
+// -*-C++-*- (for Emacs)
+
+/*************************************************************
+ *
+ *
+ * PURPOSE:
+ * The ULongType class is the superclass for all classes
+ * describing the type of a cell
+ *
+ *
+ * COMMENTS:
+ * This file is patched by O2!
+ *
+ ************************************************************/
+
+#ifndef _OCTETTYPE_HH_
+#define _OCTETTYPE_HH_
+
+#include <iostream>
+#include "integraltype.hh"
+#include "catalogmgr/ops.hh"
+
+class OId;
+
+//@ManMemo: Module: {\bf relcatalogif}.
+
+/*@Doc:
+
+OctetType is the base type used for boolean cell values (e.g. result
+of comparison operations, see \Ref{Ops}). The value of a Octet is
+stored in one char. OctetType is a persistence capable class.
+*/
+
+class OctetType : public IntegralType
+ {
+ public:
+ OctetType(const OId& id);
+
+ OctetType();
+ /*@Doc:
+ default constructor, no initialization needed for OctetType.
+ */
+
+ OctetType(const OctetType& old);
+ /*@Doc:
+ copy constructor.
+ */
+
+ OctetType& operator=(const OctetType& old);
+ /*@Doc:
+ assignment operator.
+ */
+
+ virtual ~OctetType();
+ /*@Doc:
+ virtual destructor.
+ */
+
+ virtual void printCell(ostream& stream, const char* cell) const;
+ /*@Doc:
+ */
+
+ virtual r_Long* convertToCLong(const char* cell, r_Long* value) const;
+ /*@Doc:
+ */
+
+ virtual char* makeFromCLong(char* cell, const r_Long* value) const;
+
+ static const char* Name;
+
+ protected:
+
+ virtual void readFromDb() throw (r_Error);
+ /*@Doc:
+ initializes the attributes of this type.
+ there is no database activity. this is hard coded.
+ */
+
+ };
+
+#endif
diff --git a/relcatalogif/realtype.hh b/relcatalogif/realtype.hh
new file mode 100644
index 0000000..08c9752
--- /dev/null
+++ b/relcatalogif/realtype.hh
@@ -0,0 +1,90 @@
+/*
+* 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>.
+*/
+/*************************************************************
+ *
+ *
+ * PURPOSE:
+ * The RealType class is the superclass for floating point
+ * types (Float, Double) describing the type of a
+ * cell
+ *
+ *
+ * COMMENTS:
+ *
+ ************************************************************/
+
+#ifndef _REALTYPE_HH_
+#define _REALTYPE_HH_
+
+#include "atomictype.hh"
+
+//@ManMemo: Module: {\bf relcatalogif}.
+
+/*@Doc:
+RealType is the abstract base class for floating point
+\Ref{BaseType} subclasses, \Ref{Float} or \Ref{Double}.
+It provides conversions to/from long and unsigned long
+It's subclasses must implement conversions to/from double
+*/
+
+class RealType : public AtomicType {
+public:
+ RealType(unsigned int newSize):
+ AtomicType(newSize) {}
+ /*@Doc:
+ constructor.
+ */
+
+ RealType(const RealType& old):
+ AtomicType(old) {}
+ /*@Doc:
+ copy constructor.
+ */
+
+ RealType(const OId& id) throw (r_Error):
+ AtomicType(id) {}
+ /*@Doc:
+ */
+
+ virtual ~RealType() {}
+ /*@Doc:
+ */
+
+ virtual r_ULong* convertToCULong(const char*, r_ULong*) const;
+ virtual char* makeFromCULong(char*, const r_ULong*) const;
+
+ virtual r_Long* convertToCLong(const char*, r_Long*) const;
+ virtual char* makeFromCLong(char*, const r_Long*) const;
+
+protected:
+ RealType(const char* name, unsigned int newSize):
+ AtomicType(name, newSize) {}
+ /*@Doc:
+ */
+};
+
+#include "realtype.icc"
+
+#endif
+
+
diff --git a/relcatalogif/realtype.icc b/relcatalogif/realtype.icc
new file mode 100644
index 0000000..6460e24
--- /dev/null
+++ b/relcatalogif/realtype.icc
@@ -0,0 +1,52 @@
+/*
+* 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>.
+*/
+/*************************************************************
+*
+*
+* COMMENTS:
+*
+************************************************************/
+
+inline r_ULong*
+RealType::convertToCULong(const char* cell, r_ULong* value) const {
+ double tmp;
+ *value = (r_ULong) *this->convertToCDouble(cell, &tmp);
+ return value;
+}
+
+inline r_Long*
+RealType::convertToCLong(const char* cell, r_Long* value) const {
+ return (r_Long*)(this->convertToCULong(cell, (r_ULong *)value));
+}
+
+inline char*
+RealType::makeFromCULong(char* cell, const r_ULong* value) const {
+ double tmp = *value;
+ return this->makeFromCDouble(cell, &tmp);
+}
+
+inline char*
+RealType::makeFromCLong(char* cell, const r_Long* value) const {
+ return this->makeFromCULong(cell, (r_ULong *)value);
+}
+
diff --git a/relcatalogif/settype.hh b/relcatalogif/settype.hh
new file mode 100644
index 0000000..7c62200
--- /dev/null
+++ b/relcatalogif/settype.hh
@@ -0,0 +1,82 @@
+// -*-C++-*- (for Emacs)
+
+/*
+* 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>.
+*/
+/*************************************************************
+ *
+ *
+ * PURPOSE:
+ * The SetType class represents the type for sets of MDD
+ * objects.
+ *
+ *
+ * COMMENTS:
+ *
+ ************************************************************/
+
+#ifndef _SETTYPE_HH_
+#define _SETTYPE_HH_
+
+class SetType;
+
+#include <iostream>
+#include "collectiontype.hh"
+#include "catalogmgr/ops.hh"
+class OId;
+
+//@ManMemo: Module: {\bf relcatalogif}.
+
+/*@Doc:
+ The SetType class represents the type for sets of MDD
+ objects.
+*/
+
+class SetType : public CollectionType
+{
+public:
+ SetType(const OId& id) throw (r_Error);
+
+ virtual char* getTypeStructure() const;
+
+ /// constructor receiving pointer to an MDDType (or subclass).
+ SetType(const char* newTypeName, const MDDType* newMDDType);
+ /// default constructor, cannot be used.
+ SetType();
+ /// copy constructor.
+ SetType(const SetType& old);
+ /// assignment operator.
+ SetType& operator=(const SetType& old);
+
+ /// virtual destructor.
+ virtual ~SetType();
+
+protected:
+
+ virtual void deleteFromDb() throw (r_Error);
+
+ virtual void insertInDb() throw (r_Error);
+
+ virtual void readFromDb() throw (r_Error);
+};
+
+#endif
diff --git a/relcatalogif/settype.lis b/relcatalogif/settype.lis
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/relcatalogif/settype.lis
diff --git a/relcatalogif/settype.pgc b/relcatalogif/settype.pgc
new file mode 100644
index 0000000..4d8ba82
--- /dev/null
+++ b/relcatalogif/settype.pgc
@@ -0,0 +1,140 @@
+// This is -*- C++ -*-
+
+/*
+* 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>.
+*/
+/*************************************************************
+ *
+ *
+ * PURPOSE:
+ * Code with embedded SQL for PostgreSQL DBMS
+ *
+ *
+ * COMMENTS:
+ * uses embedded SQL
+ *
+ ************************************************************/
+
+#include "debug-srv.hh"
+
+// general embedded SQL related definitions
+EXEC SQL include "../reladminif/sqlglobals.h";
+
+#include "settype.hh"
+#include "mddtype.hh"
+#include "reladminif/sqlerror.hh"
+#include "raslib/rmdebug.hh"
+#include "reladminif/objectbroker.hh"
+
+void
+SetType::insertInDb() throw (r_Error)
+{
+ RMDBGENTER(5, RMDebug::module_catalogif, "SetType", "insertInDb() " << myOId << " " << getTypeName());
+
+ EXEC SQL BEGIN DECLARE SECTION;
+ double mddtypeid;
+ char settypename[VARCHAR_MAXLEN];
+ long settypeid;
+ EXEC SQL END DECLARE SECTION;
+
+ (void) strncpy( settypename, (char*) getTypeName(), (size_t) sizeof(settypename) );
+ settypeid = myOId.getCounter();
+ mddtypeid = getMDDType()->getOId();
+
+ // TALK( "EXEC SQL INSERT INTO RAS_SETTYPES ( SetTypeId, SetTypeName, MDDTypeOId) VALUES( " << settypeid << ", " << settypename << ", " << mddtypeid << " )" );
+ EXEC SQL INSERT INTO RAS_SETTYPES ( SetTypeId, SetTypeName, MDDTypeOId)
+ VALUES ( :settypeid, :settypename, :mddtypeid);
+ if (SQLCODE != SQLOK)
+ {
+ check("SetType::insertInDb()");
+ LEAVE("SetType::insertInDb() error: " << SQLCODE );
+ generateException();
+ }
+
+ DBObject::insertInDb();
+
+ RMDBGEXIT(5, RMDebug::module_catalogif, "SetType", "insertInDb() " << myOId);
+}
+
+void
+SetType::deleteFromDb() throw (r_Error)
+{
+ RMDBGENTER(5, RMDebug::module_catalogif, "SetType", "deleteFromDb() " << myOId << " " << getTypeName());
+ EXEC SQL BEGIN DECLARE SECTION;
+ long settypeid3;
+ EXEC SQL END DECLARE SECTION;
+
+ settypeid3 = myOId.getCounter();
+
+ TALK( "EXEC SQL DELETE FROM RAS_SETTYPES WHERE RAS_SETTYPES.SetTypeId = " << settypeid3 );
+ EXEC SQL DELETE FROM RAS_SETTYPES WHERE RAS_SETTYPES.SetTypeId = :settypeid3;
+ if (SQLCODE != SQLOK)
+ {
+ check("SetType::deleteFromDb()");
+ LEAVE("SetType::deleteFromDb() error: " << SQLCODE );
+ generateException();
+ }
+ DBObject::deleteFromDb();
+ RMDBGEXIT(5, RMDebug::module_catalogif, "SetType", "deleteFromDb() " << myOId);
+}
+
+void
+SetType::readFromDb() throw (r_Error)
+{
+ RMDBGENTER(5, RMDebug::module_catalogif, "SetType", "readFromDb() " << myOId);
+#ifdef RMANBENCHMARK
+ DBObject::readTimer.resume();
+#endif
+ EXEC SQL BEGIN DECLARE SECTION;
+ double mddtypeid1;
+ char settypename1[VARCHAR_MAXLEN];
+ long settypeid1;
+ EXEC SQL END DECLARE SECTION;
+
+ settypeid1 = myOId.getCounter();
+ mddtypeid1 = 0;
+
+ TALK( "EXEC SQL SELECT SetTypeName, MDDTypeOId INTO :settypename1, :mddtypeid1 FROM RAS_SETTYPES WHERE SetTypeId = " << settypeid1 );
+ EXEC SQL SELECT SetTypeName, MDDTypeOId
+ INTO :settypename1, :mddtypeid1
+ FROM RAS_SETTYPES
+ WHERE SetTypeId = :settypeid1;
+ if (check("SetType::readFromDb()") != 0)
+ {
+ if (SQLCODE == SQLNODATAFOUND) // was: 100 -- PB 2005-feb-13
+ throw r_Error(r_Error::r_Error_ObjectUnknown);
+ else
+ generateException();
+ }
+
+ setName(settypename1);
+ myType = SETTYPE;
+ myMDDType = (MDDType*)ObjectBroker::getObjectByOId(OId(mddtypeid1));
+ DBObject::readFromDb();
+
+#ifdef RMANBENCHMARK
+ DBObject::readTimer.pause();
+#endif
+
+ RMDBGEXIT(5, RMDebug::module_catalogif, "SetType", "readFromDb() " << myOId);
+}
+
diff --git a/relcatalogif/settypecommon.cc b/relcatalogif/settypecommon.cc
new file mode 100644
index 0000000..c05e74c
--- /dev/null
+++ b/relcatalogif/settypecommon.cc
@@ -0,0 +1,89 @@
+/*
+* 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>.
+*/
+#include "mymalloc/mymalloc.h"
+#include <malloc.h>
+#include "settype.hh"
+#include <stdlib.h>
+#include <string.h>
+#include "reladminif/sqlerror.hh"
+#include "reladminif/externs.h"
+#include "raslib/rmdebug.hh"
+#include "reladminif/objectbroker.hh"
+#include "mddtype.hh"
+
+
+SetType::SetType(const OId& id) throw (r_Error)
+ : CollectionType(id)
+ {
+ objecttype = OId::SETTYPEOID;
+ readFromDb();
+ }
+
+char*
+SetType::getTypeStructure() const
+ {
+ char* dummy = myMDDType->getTypeStructure();
+ char* result = (char*)mymalloc(5 + strlen(dummy) + 2);
+
+ strcpy(result, "set <");
+ strcat(result, dummy);
+ strcat(result, ">");
+
+ free(dummy);
+ return result;
+ }
+
+SetType::SetType(const char* newTypeName, const MDDType* newMDDType)
+ : CollectionType(newTypeName, newMDDType)
+ {
+ myType = SETTYPE;
+ objecttype = OId::SETTYPEOID;
+ }
+
+SetType::SetType(const SetType& old)
+ : CollectionType(old)
+ {
+ }
+
+SetType& SetType::operator=(const SetType& old)
+ {
+ // Gracefully handle self assignment
+ if (this == &old)
+ return *this;
+ CollectionType::operator=(old);
+ return *this;
+ }
+
+SetType::SetType()
+ : CollectionType("unnamed settype")
+ {
+ myType = SETTYPE;
+ objecttype = OId::SETTYPEOID;
+ }
+
+SetType::~SetType()
+ {
+ RMDBGENTER(4, RMDebug::module_catalogif, "SetType", "~SetType() " << myOId);
+ validate();
+ RMDBGEXIT(4, RMDebug::module_catalogif, "SetType", "~SetType() " << myOId);
+ }
diff --git a/relcatalogif/shorttype.C b/relcatalogif/shorttype.C
new file mode 100644
index 0000000..4827243
--- /dev/null
+++ b/relcatalogif/shorttype.C
@@ -0,0 +1,153 @@
+/*
+* 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>.
+*/
+/*************************************************************
+ *
+ *
+ * PURPOSE:
+ * uses ODMG-conformant O2 classes
+ *
+ *
+ * COMMENTS:
+ * none
+ *
+ ************************************************************/
+
+static const char rcsid[] = "@(#)catalogif,ShortType: $Header: /home/rasdev/CVS-repository/rasdaman/relcatalogif/shorttype.C,v 1.11 2003/12/27 23:23:04 rasdev Exp $";
+
+#include "shorttype.hh"
+#include <iomanip>
+#include <limits.h>
+#include <string.h>
+
+ShortType::ShortType(const OId& id) throw (r_Error)
+ :IntegralType(id)
+ {
+ readFromDb();
+ }
+
+/*************************************************************
+ * Method name...: ShortType();
+ *
+ * Arguments.....: none
+ * Return value..: none
+ * Description...: initializes member variables for an
+ * ShortType.
+ ************************************************************/
+
+ShortType::ShortType()
+ : IntegralType(ShortType::Name, 2)
+ {
+ myType = SHORT;
+ myOId = OId(SHORT, OId::ATOMICTYPEOID);
+ }
+
+/*************************************************************
+ * Method name...: ShortType(const ShortType& old);
+ *
+ * Arguments.....: none
+ * Return value..: none
+ * Description...: copy constructor
+ ************************************************************/
+
+ShortType::ShortType(const ShortType& old)
+ : IntegralType(old)
+ {
+ }
+
+/*************************************************************
+ * Method name...: operator=(const ShortType&);
+ *
+ * Arguments.....: none
+ * Return value..: none
+ * Description...: copy constructor
+ ************************************************************/
+
+ShortType& ShortType::operator=(const ShortType& old)
+ {
+ // Gracefully handle self assignment
+ if (this == &old)
+ return *this;
+ AtomicType::operator=(old);
+ return *this;
+ }
+
+/*************************************************************
+ * Method name...: ~ShortType();
+ *
+ * Arguments.....: none
+ * Return value..: none
+ * Description...: virtual destructor
+ ************************************************************/
+
+ShortType::~ShortType()
+{
+}
+
+/*************************************************************
+ * Method name...: void printCell( ostream& stream,
+ * const char* cell )
+ *
+ * Arguments.....:
+ * stream: stream to print on
+ * cell: pointer to cell to print
+ * Return value..: none
+ * Description...: prints a cell cell in hex on stream
+ * followed by a space.
+ * Assumes that Short is stored MSB..LSB
+ * on HP.
+ ************************************************************/
+
+void
+ShortType::printCell( ostream& stream, const char* cell ) const
+{
+ stream << std::setw(5) << *(short*)cell;
+}
+
+r_Long*
+ShortType::convertToCLong(const char* cell, r_Long* value) const
+{
+ *value = *(short*)cell;
+ return value;
+}
+
+
+char*
+ShortType::makeFromCLong(char* cell, const r_Long* value) const
+{
+ r_Long myLong = *value;
+ // restricting long to value range of short
+ myLong = myLong > SHRT_MAX ? SHRT_MAX : myLong;
+ myLong = myLong < SHRT_MIN ? SHRT_MIN : myLong;
+ // !!!! HP specific, assumes 2 Byte short
+ *(short*)(cell) = (short)myLong;
+ return cell;
+}
+
+void
+ShortType::readFromDb() throw (r_Error)
+ {
+ setName(ShortType::Name);
+ myType = SHORT;
+ size = 2;
+ myOId = OId(SHORT, OId::ATOMICTYPEOID);
+ }
diff --git a/relcatalogif/shorttype.hh b/relcatalogif/shorttype.hh
new file mode 100644
index 0000000..75b701e
--- /dev/null
+++ b/relcatalogif/shorttype.hh
@@ -0,0 +1,104 @@
+// -*-C++-*- (for Emacs)
+
+/*
+* 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>.
+*/
+/*************************************************************
+ *
+ *
+ * PURPOSE:
+ * The ShortType class is the superclass for all classes
+ * describing the type of a cell
+ *
+ *
+ * COMMENTS:
+ * This file is patched by O2!
+ *
+ ************************************************************/
+
+#ifndef _SHORTTYPE_HH_
+#define _SHORTTYPE_HH_
+
+#include <iostream>
+#include "integraltype.hh"
+#include "catalogmgr/ops.hh"
+
+class OId;
+
+//@ManMemo: Module: {\bf relcatalogif}.
+
+/*@Doc:
+ShortType is the base type used for 16bit integer cell
+values. The value of a Short is stored in four chars.
+
+*/
+
+class ShortType : public IntegralType
+ {
+ public:
+ ShortType(const OId& id) throw (r_Error);
+
+ ShortType();
+ /*@Doc:
+ default constructor, sets type name to "Short".
+ */
+
+ ShortType(const ShortType& old);
+ /*@Doc:
+ copy constructor.
+ */
+
+ ShortType& operator=(const ShortType& old);
+ /*@Doc:
+ assignment operator.
+ */
+
+ virtual ~ShortType();
+ /*@Doc:
+ virtual destructor.
+ */
+
+ virtual void printCell(ostream& stream, const char* cell) const;
+ /*@Doc:
+ */
+
+ virtual r_Long* convertToCLong(const char* cell, r_Long* value) const;
+ /*@Doc:
+ */
+
+ virtual char* makeFromCLong(char* cell, const r_Long* value) const;
+ /*@Doc:
+ */
+
+ static const char* Name;
+
+ protected:
+
+ virtual void readFromDb() throw (r_Error);
+ /*@Doc:
+ initializes the attributes of this type.
+ there is no database activity. this is hard coded.
+ */
+
+ };
+
+#endif
diff --git a/relcatalogif/structtype.hh b/relcatalogif/structtype.hh
new file mode 100644
index 0000000..7adbfc2
--- /dev/null
+++ b/relcatalogif/structtype.hh
@@ -0,0 +1,173 @@
+// -*-C++-*- (for Emacs)
+
+/*
+* 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>.
+*/
+/*************************************************************
+ *
+ *
+ * PURPOSE:
+ * The StructType class is the superclass for all classes
+ * describing the type of a cell
+ *
+ *
+ * COMMENTS:
+ *
+ ************************************************************/
+
+#ifndef _STRUCTTYPE_HH_
+#define _STRUCTTYPE_HH_
+
+#include <iostream>
+#include <vector>
+
+#include "compositetype.hh"
+#include "catalogmgr/ops.hh"
+
+class BaseType;
+
+//@ManMemo: Module: {\bf relcatalogif}.
+
+/*@Doc:
+StructType is the base type used for user defined structures. It
+stores the names and BaseTypes of the elements. The size of a
+StructType in chars depends on the elements.
+
+StructType now uses alignment for structures with elements of
+different sizes. One byte types are aligned to one byte, two byte
+types to two, all other types to four. The Size is padded to 4 byte
+alignment except for types with only chars (one byte alignment) or
+type with only shorts (two byte alignment). Structs as elements of
+structs are aligned with the minimum byte alignment needed for the
+struct.
+
+*/
+
+class StructType : public CompositeType
+ {
+ // friend ostream& operator << (ostream& stream, StructType& b);
+
+ public:
+ virtual void printCell(ostream& stream, const char* cell) const;
+
+ virtual char* getTypeStructure() const;
+
+ /// add new element to struct
+ unsigned int addElement(const char* elemName, const char* elemType);
+
+ /// add new element to struct using pointer to BaseType
+ unsigned int addElement(const char* elemName, const BaseType* elemType);
+
+ /// get offset for an element by name of element.
+ unsigned int getOffset(const char* elemName) const;
+
+ /// get offset for an element by number of element (0 based).
+ unsigned int getOffset(unsigned int num) const;
+
+ /// get type of an element by name of element.
+ const BaseType* getElemType(const char* elemName) const;
+
+ /// get name of an element by number of element (0 based).
+ const char* const getElemName(unsigned int num) const;
+
+ /// get type of an element by number of element (0 based).
+ const BaseType* getElemType(unsigned int num) const;
+
+ /// get number of elements.
+ unsigned int getNumElems() const;
+
+ /// get alignment needed for structure to be embedded in another structure.
+ unsigned int getAlignment() const;
+
+ /// checks if a certain StructType is contained in this StructType
+ int contains(const StructType* aStruct) const;
+
+ StructType(const OId& structtypeid) throw (r_Error);
+
+ /// default constructor, sets type name to "".
+ StructType();
+
+ /// constructor getting type name and number of elements.
+ StructType(const char* newTypeName, unsigned int numElem );
+
+ /// copy constructor.
+ StructType( const StructType& old );
+
+ /// assignment operator.
+ StructType& operator=( const StructType& old );
+
+ /// virtual destructor.
+ virtual ~StructType();
+
+ virtual int compatibleWith(const Type* aType) const;
+
+ virtual r_Bytes getMemorySize() const;
+
+private:
+ // those inherited from BaseType aren't useful at all for StructType
+ // made them private to preven calling them
+ virtual r_ULong* convertToCULong(const char* cell, r_ULong* value) const;
+ virtual char* makeFromCULong(char* cell, const r_ULong* value) const;
+ virtual r_Long* convertToCLong(const char* cell, r_Long* value) const;
+ virtual char* makeFromCLong(char* cell, const r_Long* value) const;
+ virtual double* convertToCDouble(const char* cell, double* value) const;
+ virtual char* makeFromCDouble(char* cell, const double* value) const;
+
+
+ protected:
+
+ virtual void insertInDb() throw (r_Error);
+
+ virtual void deleteFromDb() throw (r_Error);
+
+ virtual void readFromDb() throw (r_Error);
+
+ // moves back one step all elements all elements behind pos
+ void moveBack(int pos);
+
+ // calculates and sets current size of type with alignment
+ void calcSize();
+
+ /// Array containing references to base types of elements.
+ std::vector< const BaseType* > elements;
+
+ /// Array containing names of elements.
+ std::vector< char* > elementNames;
+
+ /// Array containing offsets to elements
+ std::vector< unsigned int > elementOffsets;
+
+ /// The number of elements.
+ unsigned int numElems;
+
+ /// Alignment needed for structure if embedded in other structures.
+ unsigned int align;
+
+ /// add new element to struct using pointer to BaseType
+ /// does the actuall adding. the public method will not let a persitent type
+ /// be changed
+ unsigned int addElementPriv(const char* elemName, const BaseType* elemType);
+ };
+
+#include "structtype.icc"
+
+#endif
diff --git a/relcatalogif/structtype.icc b/relcatalogif/structtype.icc
new file mode 100644
index 0000000..788d996
--- /dev/null
+++ b/relcatalogif/structtype.icc
@@ -0,0 +1,54 @@
+/*
+* 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>.
+*/
+/*************************************************************
+*
+*
+* COMMENTS:
+*
+************************************************************/
+
+// those would better throw an exception
+
+inline r_ULong* StructType::convertToCULong(const char* cell, r_ULong* value) const {
+ return 0;
+}
+
+inline char* StructType::makeFromCULong(char* cell, const r_ULong* value) const {
+ return 0;
+}
+
+inline r_Long* StructType::convertToCLong(const char* cell, r_Long* value) const {
+ return 0;
+}
+
+inline char* StructType::makeFromCLong(char* cell, const r_Long* value) const {
+ return 0;
+}
+
+inline double* StructType::convertToCDouble(const char* cell, double* value) const {
+ return 0;
+}
+
+inline char* StructType::makeFromCDouble(char* cell, const double* value) const {
+ return 0;
+}
diff --git a/relcatalogif/structtype.lis b/relcatalogif/structtype.lis
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/relcatalogif/structtype.lis
diff --git a/relcatalogif/structtype.pgc b/relcatalogif/structtype.pgc
new file mode 100644
index 0000000..d1d1e24
--- /dev/null
+++ b/relcatalogif/structtype.pgc
@@ -0,0 +1,214 @@
+#include "mymalloc/mymalloc.h"
+// This is -*- C++ -*-
+/*
+* 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>.
+*/
+/*************************************************************
+ *
+ *
+ * PURPOSE:
+ * Code with embedded SQL for PostgreSQL DBMS
+ *
+ *
+ * COMMENTS:
+ * uses embedded SQL
+ *
+ ************************************************************/
+
+static const char rcsid[] = "@(#)catalogif,StructType: $Header: /home/rasdev/CVS-repository/rasdaman/relcatalogif/structtype.ec,v 1.4 2003/12/27 23:23:04 rasdev Exp $";
+
+// general embedded SQL related definitions
+EXEC SQL include "../reladminif/sqlglobals.h";
+
+#include "debug-srv.hh"
+#include "structtype.hh"
+#include "raslib/rmdebug.hh"
+#include "reladminif/sqlerror.hh"
+#include "reladminif/externs.h"
+#include "reladminif/objectbroker.hh"
+
+
+void
+StructType::insertInDb() throw (r_Error)
+{
+ RMDBGENTER(5, RMDebug::module_catalogif, "StructType", "insertInDb() " << myOId);
+ EXEC SQL BEGIN DECLARE SECTION;
+ long structtypeid;
+ char structtypename[VARCHAR_MAXLEN];
+ double elementtype;
+ char elementname[VARCHAR_MAXLEN];
+ short count;
+ EXEC SQL END DECLARE SECTION;
+
+ (void) strncpy( structtypename, (char*) getTypeName(), (size_t) sizeof(structtypename) );
+ structtypeid = myOId.getCounter();
+
+ TALK( "EXEC SQL INSERT INTO RAS_BASETYPENAMES ( BaseTypeId, BaseTypeName) VALUES ( " << structtypeid << ", " << structtypename << ")" );
+ EXEC SQL INSERT INTO RAS_BASETYPENAMES ( BaseTypeId, BaseTypeName)
+ VALUES ( :structtypeid, :structtypename);
+ if (SQLCODE != SQLOK)
+ {
+ check("StructType::insertInDb() INSERT INTO RAS_BASETYPENAMES");
+ LEAVE("StructType::insertInDb() INSERT INTO RAS_BASETYPENAMES error: " << SQLCODE );
+ generateException();
+ }
+
+ for (count = 0; count < getNumElems(); count++)
+ {
+ (void) strncpy( elementname, (char*) getElemName(count), (size_t) sizeof(elementname) );
+ //should not be necessary because of TypeFactory::addType()
+ DBObject* obj = (DBObject*)getElemType(count);
+
+ elementtype = obj->getOId();
+ RMDBGMIDDLE(6, RMDebug::module_catalogif, "StructType", "element " << count << ". id\t:" << elementtype);
+
+ TALK( "EXEC SQL INSERT INTO RAS_BASETYPES ( BaseTypeId, ContentType, Count, ContentTypeName) VALUES ( " << structtypeid << ", " << elementtype << ", " << count << ", " << elementname << ")" );
+ EXEC SQL INSERT INTO RAS_BASETYPES ( BaseTypeId, ContentType, Count, ContentTypeName )
+ VALUES ( :structtypeid, :elementtype, :count, :elementname);
+ if (SQLCODE != SQLOK)
+ {
+ check("StructType::insertInDb() INSERT INTO RAS_BASETYPES");
+ LEAVE("StructType::insertInDb() INSERT INTO RAS_BASETYPES error: " << SQLCODE );
+ generateException();
+ }
+ }
+ DBObject::insertInDb();
+ RMDBGEXIT(5, RMDebug::module_catalogif, "StructType", "insertInDb()");
+}
+
+void
+StructType::deleteFromDb() throw (r_Error)
+{
+ RMDBGENTER(5, RMDebug::module_catalogif, "StructType", "deleteFromDb() " << myOId);
+ EXEC SQL BEGIN DECLARE SECTION;
+ long basetypeid3;
+ EXEC SQL END DECLARE SECTION;
+
+ basetypeid3 = myOId.getCounter();
+
+ TALK( "EXEC SQL DELETE FROM RAS_BASETYPENAMES WHERE BaseTypeId = " << basetypeid3 );
+ EXEC SQL DELETE FROM RAS_BASETYPENAMES
+ WHERE BaseTypeId = :basetypeid3;
+ if (SQLCODE != SQLOK)
+ {
+ check("StructType::deleteFromDb() DELETE FROM RAS_BASETYPENAMES");
+ LEAVE("StructType::deleteFromDb() DELETE FROM RAS_BASETYPENAMES error: " << SQLCODE );
+ generateException();
+ }
+
+ TALK( "EXEC SQL DELETE FROM RAS_BASETYPES WHERE BaseTypeId = " << basetypeid3 );
+ EXEC SQL DELETE FROM RAS_BASETYPES
+ WHERE BaseTypeId = :basetypeid3;
+ if (SQLCODE != SQLOK)
+ {
+ check("StructType::deleteFromDb() DELETE FROM RAS_BASETYPES");
+ LEAVE("StructType::deleteFromDb() DELETE FROM RAS_BASETYPES error: " << SQLCODE );
+ generateException();
+ }
+
+ DBObject::deleteFromDb();
+ RMDBGEXIT(5, RMDebug::module_catalogif, "StructType", "deleteFromDb() " << myOId);
+}
+
+void
+StructType::readFromDb() throw (r_Error)
+{
+ RMDBGENTER(5, RMDebug::module_catalogif, "StructType", "readFromDb() " << myOId);
+ short count = 0;
+
+ EXEC SQL BEGIN DECLARE SECTION;
+ long basetypeid1;
+ double elementtypeid1;
+ char basetypename1[VARCHAR_MAXLEN];
+ char elementname1[VARCHAR_MAXLEN];
+ long count1; // added PB 2005­jan-09
+ EXEC SQL END DECLARE SECTION;
+
+ basetypeid1 = myOId.getCounter();
+
+ TALK( "EXEC SQL SELECT BaseTypeName INTO :basetypename1 FROM RAS_BASETYPENAMES WHERE BaseTypeId = " << basetypeid1 );
+ EXEC SQL SELECT BaseTypeName
+ INTO :basetypename1
+ FROM RAS_BASETYPENAMES
+ WHERE BaseTypeId = :basetypeid1;
+ if (SQLCODE != SQLOK)
+ {
+ check("StructType::readFromDb() SELECT FROM RAS_BASETYPENAMES");
+ LEAVE("StructType::readFromDb() SELECT FROM RAS_BASETYPENAMES error: " << SQLCODE );
+ if (SQLCODE == SQLNODATAFOUND) // was: 100 -- PB 2005-feb-13
+ throw r_Error(r_Error::r_Error_ObjectUnknown);
+ else
+ generateException();
+ }
+
+ setName(basetypename1);
+
+ TALK( "EXEC SQL DECLARE c CURSOR FOR SELECT ContentTypeName, ContentType, Count FROM RAS_BASETYPES WHERE BaseTypeId = " << basetypeid1 << " ORDER BY Count" );
+ EXEC SQL DECLARE c CURSOR FOR
+ SELECT ContentTypeName, ContentType, Count
+ FROM RAS_BASETYPES
+ WHERE BaseTypeId = :basetypeid1
+ ORDER BY Count;
+ if (SQLCODE != SQLOK)
+ {
+ check("StructType::readFromDb() DECLARE");
+ LEAVE("StructType::readFromDb() DECLARE error: " << SQLCODE );
+ }
+
+ TALK( "EXEC SQL OPEN c" );
+ EXEC SQL OPEN c;
+ check("StructType::readFromDb() OPEN");
+
+ do
+ {
+ memset(elementname1, 0, VARCHAR_MAXLEN);
+ // bug fix (FIXME: what about other DBMSs?), was this: -- PB 2005-jan-09
+ // EXEC SQL FETCH c INTO :elementname1, :elementtypeid1;
+ TALK( "EXEC SQL FETCH c INTO :elementname1, :elementtypeid1, :count1;" )
+ EXEC SQL FETCH c INTO :elementname1, :elementtypeid1, :count1;
+ if (SQLCODE != SQLOK)
+ {
+ if (SQLCODE != SQLNODATAFOUND) // was: 100 -- PB 2005-feb-13
+ {
+ check("StructType::readFromDb() FETCH");
+ cout << "FETCHED " << count << endl;
+ TALK( "EXEC SQL CLOSE c" );
+ EXEC SQL CLOSE c;
+ TALK( "EXEC SQL FREE c" );
+ EXEC SQL FREE c;
+ generateException();
+ }
+ break;
+ }
+ RMDBGMIDDLE(7, RMDebug::module_catalogif, "StructType", count << ". contenttypeid is " << elementtypeid1 << " elementname is " << elementname1);
+ addElementPriv((char*)elementname1, (BaseType*)ObjectBroker::getObjectByOId(OId(elementtypeid1)));
+ count++;
+ } while (1); // FIXME: make it (SQLCODE == SQLOK)
+
+ TALK( "EXEC SQL CLOSE c" );
+ EXEC SQL CLOSE c;
+
+ DBObject::readFromDb();
+
+ RMDBGEXIT(5, RMDebug::module_catalogif, "StructType", "readFromDb() " << myOId);
+}
+
diff --git a/relcatalogif/structtypecommon.cc b/relcatalogif/structtypecommon.cc
new file mode 100644
index 0000000..8c6acaa
--- /dev/null
+++ b/relcatalogif/structtypecommon.cc
@@ -0,0 +1,511 @@
+#include "mymalloc/mymalloc.h"
+// This is -*- C++ -*-
+/*
+* 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>.
+*/
+/*************************************************************
+ *
+ *
+ * PURPOSE:
+ *
+ *
+ * COMMENTS:
+ * code common to all database interface implementations
+ */
+#include "structtype.hh"
+#include "catalogmgr/typefactory.hh"
+#include <iomanip>
+#include <stdlib.h>
+#include "reladminif/sqlerror.hh"
+#include "reladminif/externs.h"
+#include "raslib/rmdebug.hh"
+#include "reladminif/objectbroker.hh"
+#include "raslib/error.hh"
+
+#include <cstring>
+
+/*************************************************************
+ * Method name...: StructType();
+ *
+ * Arguments.....: none
+ * Return value..: none
+ * Description...: initializes member variables for an
+ * StructType.
+ ************************************************************/
+
+r_Bytes
+StructType::getMemorySize() const
+ {
+ r_Bytes retval = DBNamedObject::getMemorySize() + sizeof(int) + sizeof(int) + sizeof(std::vector< BaseType* >) + sizeof(std::vector< unsigned int >) + sizeof(std::vector< char* >) + sizeof(int) * numElems + sizeof(BaseType*) * numElems;
+ for (int i = 0; i < numElems; i++)
+ retval = retval + 1 + strlen(elementNames[i]);
+ return retval;
+ }
+
+StructType::StructType()
+ : CompositeType("unnamed structtype", 0),
+ numElems(0),
+ elements(0),
+ elementNames(0),
+ elementOffsets(0),
+ align(1)
+ {
+ myType = STRUCT;
+ objecttype = OId::STRUCTTYPEOID;
+ }
+
+StructType::StructType(const char* newTypeName, unsigned int numElem )
+ : CompositeType(newTypeName, 0),
+ elements(numElem),
+ elementNames(numElem),
+ elementOffsets(numElem),
+ numElems(0),
+ align(1)
+ {
+ myType = STRUCT;
+ objecttype = OId::STRUCTTYPEOID;
+ }
+
+/*************************************************************
+ * Method name...: StructType(const StructType& old);
+ *
+ * Arguments.....: none
+ * Return value..: none
+ * Description...: copy constructor
+ ************************************************************/
+
+StructType::StructType(const StructType& old)
+ : CompositeType(old)
+ {
+ elements = old.elements;
+ elementNames = old.elementNames;
+ elementOffsets = old.elementOffsets;
+ numElems = old.numElems;
+ align = old.align;
+ }
+
+StructType::StructType(const OId& structtypeid) throw (r_Error)
+ : CompositeType(structtypeid),
+ elements(0),
+ elementNames(0),
+ elementOffsets(0),
+ numElems(0),
+ align(1)
+ {
+ RMDBGENTER(4, RMDebug::module_catalogif, "StructType", "StructType(" << myOId << ")");
+ myType = STRUCT;
+ objecttype = OId::STRUCTTYPEOID;
+ readFromDb();
+ RMDBGEXIT(4, RMDebug::module_catalogif, "StructType", "StructType(" << myOId << ")");
+ }
+
+/*************************************************************
+ * Method name...: operator=(const StructType&);
+ *
+ * Arguments.....: none
+ * Return value..: none
+ * Description...: copy constructor
+ ************************************************************/
+
+StructType&
+StructType::operator=(const StructType& old)
+ {
+ // Gracefully handle self assignment
+ //FIXME memory leak with char* in elementNames and elements
+ if (this == &old)
+ return *this;
+ CompositeType::operator=(old);
+ elements = old.elements;
+ elementNames = old.elementNames;
+ elementOffsets = old.elementOffsets;
+ numElems = old.numElems;
+ align = old.align;
+ return *this;
+ }
+
+StructType::~StructType()
+ {
+ ObjectBroker::deregisterDBObject(myOId);
+ validate();
+ for (int i = 0; i < getNumElems(); i++)
+ free((void*)elementNames[i]);//is ok because noone is using it
+ }
+
+/*************************************************************
+ * Method name...: void printCell( ostream& stream,
+ * const char* cell )
+ *
+ * Arguments.....:
+ * stream: stream to print on
+ * cell: pointer to cell to print
+ * Return value..: none
+ * Description...: prints a cell cell in hex on stream
+ * followed by a space.
+ * Assumes that Struct is stored MSB..LSB
+ * on HP.
+ ************************************************************/
+
+void
+StructType::printCell( ostream& stream, const char* cell ) const
+ {
+ int i;
+
+ stream << "\t|";
+ for(i=0; i<numElems; i++)
+ {
+ stream << elementNames[i] << "\t: ";
+ elements[i]->printCell(stream, cell + elementOffsets[i]);
+ stream << "\t ";
+ }
+ stream << "\t| ";
+ }
+
+char*
+StructType::getTypeStructure() const
+ {
+ // this implementation is not very clever, perhaps should use
+ // an intelligent string class
+ char* result = (char*)mymalloc(10);
+ char* newResult;
+ int i;
+
+ strcpy(result, "struct { ");
+ if(numElems == 0)
+ {
+ newResult = (char*)mymalloc(strlen(result) + 1 + 2);
+ strcpy(newResult, result);
+ strcat(newResult, " }");
+ free(result);
+ return newResult;
+ }
+ for(i = 0; i < numElems; i++)
+ {
+ char* dummy = elements[i]->getTypeStructure();
+ newResult = (char*)mymalloc(strlen(result) +
+ strlen(elementNames[i]) +
+ strlen(dummy) + 1 + 3 );
+ strcpy(newResult, result);
+ strcat(newResult, dummy);
+ strcat(newResult, " ");
+ strcat(newResult, elementNames[i]);
+ strcat(newResult, ", ");
+ free(result);
+ free(dummy);
+ result = newResult;
+ }
+ newResult = (char*)mymalloc(strlen(result) + 1 );
+ strcpy(newResult, result);
+ newResult[strlen(newResult) - 2] = ' ';
+ newResult[strlen(newResult) - 1] = '}';
+ free(result);
+ result = newResult;
+ return result;
+ }
+
+unsigned int
+StructType::addElement(const char* elemName, const char* elemType)
+ {
+ BaseType* stuff = 0;
+ stuff = (BaseType*)ObjectBroker::getObjectByName(OId::ATOMICTYPEOID, elemType);
+ if (stuff == 0)
+ stuff = (BaseType*)ObjectBroker::getObjectByName(OId::STRUCTTYPEOID, elemType);
+ return addElement(elemName, stuff);
+ }
+
+unsigned int
+StructType::addElement(const char* elemName, const BaseType* newType)
+ {
+ if (newType)
+ {
+ if (!_isPersistent)
+ {
+ addElementPriv(elemName, newType);
+ }
+ }
+ return numElems;
+ }
+
+unsigned int
+StructType::addElementPriv(const char* elemName, const BaseType* newType)
+ {
+ int currPos = 0;
+ int i, j;
+ char* myElemName = 0;
+
+ myElemName = (char*)mymalloc(strlen(elemName) + 1);
+ strcpy(myElemName, elemName);
+
+ if(numElems+1 > elements.size())
+ {
+ BaseType* dummyB = 0;
+ char* dummyN = 0;
+ unsigned int dummyO = 0;
+ elements.push_back(dummyB);
+ elementNames.push_back(dummyN);
+ elementOffsets.push_back(dummyO);
+ }
+ if(numElems == 0)
+ {
+ // first element
+ elementOffsets[currPos] = 0;
+ ++numElems;
+ }
+ else {
+ // All cases have to set currPos and numElems correctly!
+ // The array has to be ordered by offsets.
+ if(newType->getType() == STRUCT)
+ {
+ unsigned int myAlign = ((StructType*)(newType))->getAlignment();
+ if( align < myAlign )
+ align = myAlign;
+ // append at the end, align offset to 4 bytes.
+ currPos = numElems;
+ ++numElems;
+ elementOffsets[currPos] = ((elementOffsets[currPos-1] +
+ elements[currPos-1]->getSize()-1)/myAlign+1)*myAlign;
+ }
+ else {
+ if(newType->getSize() >= 4)
+ {
+ if(align < 4)
+ align = 4;
+ // append at the end, align offset to 4 bytes.
+ currPos = numElems;
+ ++numElems;
+ elementOffsets[currPos] = ((elementOffsets[currPos-1] +
+ elements[currPos-1]->getSize()-1)/4+1)*4;
+ }
+ else {
+ if(newType->getSize() == 2)
+ {
+ if(align < 2)
+ align = 2;
+ currPos = numElems;
+ numElems++;
+ elementOffsets[currPos] = ((elementOffsets[currPos-1] +
+ elements[currPos-1]->getSize()-1)/2+1)*2;
+ }
+ else {
+ if(newType->getSize() == 1)
+ {
+ currPos = numElems;
+ numElems++;
+ elementOffsets[currPos] = elementOffsets[currPos-1] +
+ elements[currPos-1]->getSize();
+ }
+ else {
+ RMDBGONCE(0, RMDebug::module_catalogif,"StructType", "addType() ERROR!");
+ // for debugging purposes only, shouldn't happen.
+ }
+ }
+ }
+ }
+ }
+ // actually insert type and name of element
+ elements[currPos] = newType;
+ elementNames[currPos] = myElemName;
+ // calculate current size
+ calcSize();
+ return numElems;
+ }
+
+unsigned int
+StructType::getOffset(const char* elemName) const
+ {
+ RMDBGENTER(6, RMDebug::module_catalogif, "StructType", "getOffset(" << elemName << ") " << getName() << " " << myOId);
+ int i;
+ unsigned int retval = 0;
+ bool found = false;
+ for(i=0; i<numElems; i++)
+ {
+ if(strcmp(elementNames[i], elemName) == 0)
+ {
+ retval = elementOffsets[i];
+ found = true;
+ break;
+ }
+ }
+RMDBGIF(0, RMDebug::module_catalogif, "StructType", \
+ if (found == false) \
+ { \
+ RMDBGONCE(0, RMDebug::module_catalogif, "StructType", "ERROR in StructType::getOffset(" << elemName << ") name not found " << getName() << " " << myOId << " retval " << retval); \
+ throw r_Error(STRUCTTYPE_ELEMENT_UNKNOWN); \
+ } )
+ RMDBGEXIT(6, RMDebug::module_catalogif, "StructType", "getOffset(" << elemName << ") " << getName() << " " << myOId << " retval " << retval);
+ return retval;
+ // should raise exception!
+ }
+
+unsigned int
+StructType::getOffset(unsigned int num) const
+ {
+ if (num >= numElems)
+ {
+ RMDBGONCE(0, RMDebug::module_catalogif, "StructType", "ERROR in StructType::getOffset(" << num << ") offset out of bounds " << getName() << " retval " << 0);
+ RMDBGIF(0, RMDebug::module_catalogif, "StructType", throw r_Error(STRUCTTYPE_ELEMENT_OUT_OF_BOUNDS); )
+ return 0;
+ }
+ return elementOffsets[num];
+ }
+
+const BaseType*
+StructType::getElemType(const char* elemName) const
+ {
+ RMDBGENTER(6, RMDebug::module_catalogif, "StructType", "getElemType(" << elemName << ") " << getName() << " " << myOId);
+ const BaseType* retval = 0;
+ int i;
+
+ for(i=0; i<numElems; i++)
+ {
+ if(strcmp(elementNames[i], elemName) == 0)
+ {
+ retval = elements[i];
+ break;
+ }
+ }
+ RMDBGIF(0, RMDebug::module_catalogif, "StructType", \
+ if (retval == 0) \
+ { \
+ RMDBGMIDDLE(0, RMDebug::module_catalogif, "StructType", "ERROR in StructType::getElemType(" << elemName << ") name not found " << getName() << " " << myOId << " retval " << retval); \
+ throw r_Error(STRUCTTYPE_ELEMENT_UNKNOWN); \
+ } )
+ RMDBGEXIT(6, RMDebug::module_catalogif, "StructType", "getElemType(" << elemName << ") " << getName() << " " << myOId << " retval " << retval);
+ return retval;
+ }
+
+const BaseType*
+StructType::getElemType(unsigned int num) const
+ {
+ if(!(num < numElems))
+ {
+ RMDBGONCE(0, RMDebug::module_catalogif, "StructType", "ERROR in StructType::getElemType(" << num << ") offset out of bounds " << getName() << " retval " << 0);
+ RMDBGIF(0, RMDebug::module_catalogif, "StructType", throw r_Error(STRUCTTYPE_ELEMENT_OUT_OF_BOUNDS); )
+ return 0;
+ }
+ return elements[num];
+ }
+
+const char* const
+StructType::getElemName(unsigned int num) const
+ {
+ if(!(num < numElems))
+ {
+ RMDBGONCE(0, RMDebug::module_catalogif, "StructType", "ERROR in StructType::getElemName(" << num << ") offset out of bounds " << getName() << " retval " << 0);
+ RMDBGIF(0, RMDebug::module_catalogif, "StructType", throw r_Error(STRUCTTYPE_ELEMENT_OUT_OF_BOUNDS); )
+ return 0;
+ }
+ return elementNames[num];
+ }
+
+unsigned int
+StructType::getNumElems() const
+ {
+ return numElems;
+ }
+
+unsigned int
+StructType::getAlignment() const
+ {
+ return align;
+ }
+
+int
+StructType::contains(const StructType* aStruct) const
+ {
+ int i;
+
+ for(i=0; i<numElems; i++)
+ {
+ if(elements[i] == aStruct)
+ return 1;
+ else
+ if(elements[i]->getType() == STRUCT)
+ if(((StructType*)elements[i])->contains(aStruct))
+ return 1;
+ }
+ return 0;
+ }
+
+int
+StructType::compatibleWith(const Type* aType) const
+ {
+ RMDBGENTER(7, RMDebug::module_catalogif, "StructType", "compatibleWith(" << aType->getName() << ") " << getName());
+ int retval;
+ if(aType->getType() != STRUCT)
+ {
+ RMDBGMIDDLE(8, RMDebug::module_catalogif, "StructType", "no structtype");
+ retval = 0;
+ }
+ else {
+ if(elements.size() != ((StructType*)aType)->elements.size())
+ {
+ RMDBGMIDDLE(8, RMDebug::module_catalogif, "StructType", "not the same size");
+ retval = 0;
+ }
+ else {
+ const BaseType* myBaseType;
+ const BaseType* otherBaseType;
+
+ int i;
+
+ retval = 1;
+ for( i = 0; i < elements.size(); i++ )
+ {
+ myBaseType = elements[i];
+ otherBaseType = ((StructType*)aType)->elements[i];
+ if(!myBaseType->compatibleWith(otherBaseType))
+ {
+ RMDBGMIDDLE(8, RMDebug::module_catalogif, "StructType", i << ". element " << otherBaseType->getName() << " does not match " << myBaseType);
+ retval = 0;
+ break;
+ }
+ }
+ }
+ }
+ RMDBGEXIT(7, RMDebug::module_catalogif, "StructType", "compatibleWith(" << aType->getName() << ") " << getName() << " retval " << retval);
+ return retval;
+ }
+
+void
+StructType::calcSize()
+ {
+ int alignSize = 1;
+
+ // check for alignment of size
+ for(int i=0; i<numElems; i++)
+ {
+ if( elements[i]->getSize() == 4 || elements[i]->getType() == STRUCT )
+ {
+ alignSize = 4;
+ break;
+ }
+ else {
+ if( elements[i]->getSize() == 2 )
+ {
+ alignSize = 2;
+ }
+ }
+ }
+ // align size to alignSize bytes (there may be unused bytes at the end!)
+ size = ((elementOffsets[numElems-1]+elements[numElems-1]->getSize()-1)/alignSize+1)*alignSize;
+ }
+
diff --git a/relcatalogif/type.C b/relcatalogif/type.C
new file mode 100644
index 0000000..5b496b2
--- /dev/null
+++ b/relcatalogif/type.C
@@ -0,0 +1,138 @@
+#include "mymalloc/mymalloc.h"
+/*
+* 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>.
+*/
+/*************************************************************
+ *
+ *
+ * PURPOSE:
+ * uses ODMG-conformant O2 classes
+ *
+ *
+ * COMMENTS:
+ * none
+ *
+ ************************************************************/
+
+#include <stdlib.h>
+#include <cstring>
+#include <ctype.h>
+#include "type.hh"
+#include "raslib/rmdebug.hh"
+#include "reladminif/externs.h"
+
+/************************************************************
+ * Method name...: Type()
+ *
+ * Arguments.....: none
+ * Return value..: none
+ * Description...: constructor
+ ************************************************************/
+
+Type::Type()
+ : DBNamedObject("unnamed type")
+ {
+ RMDBGONCE(4, RMDebug::module_catalogif, "Type", "Type()");
+ }
+
+Type::Type(const OId& id) throw (r_Error)
+ : DBNamedObject(id)
+ {
+ RMDBGONCE(4, RMDebug::module_catalogif, "Type", "Type(" << myOId << ")");
+ }
+
+Type::Type(const char* name)
+ : DBNamedObject(name)
+ {
+ RMDBGONCE(4, RMDebug::module_catalogif, "Type", "Type(" << name << ")");
+ }
+
+Type::Type(const Type& old)
+ : DBNamedObject(old)
+ {
+ myType = old.myType;
+ }
+
+Type&
+Type::operator=(const Type& old)
+ {
+ DBNamedObject::operator=(old);
+ myType = old.myType;
+ return *this;
+ }
+
+void
+Type::destroy()
+ {
+ //does nothing to prevent types from being deleted because of reference counts
+ }
+
+/*************************************************************
+ * Method name...: getTypeName()
+ *
+ * Arguments.....: none
+ * Return value..:
+ * name of the type as a C string.
+ * Description...: returns name of the type.
+ ************************************************************/
+
+const char*
+Type::getTypeName() const
+{
+ return getName();
+}
+
+char*
+Type::getTypeStructure() const
+{
+ // default implementation for all non-structured base types.
+ char* dummy = (char*)getTypeName();
+ char* result = (char*)mymalloc(strlen(dummy) + 1);
+ strcpy(result, dummy);
+ for(int i = 0; i < strlen(dummy); i++)
+ result[i] = tolower(result[i]);
+ return result;
+}
+
+const TypeEnum
+Type::getType() const
+{
+ return myType;
+}
+
+int
+Type::compatibleWith(const Type* /* aType */) const
+{
+ return 0;
+}
+
+/*************************************************************
+ * Method name...: ~Type()
+ *
+ * Arguments.....: none
+ * Return value..: none
+ * Description...: virtual destructor
+ ************************************************************/
+
+Type::~Type()
+ {
+ }
diff --git a/relcatalogif/type.hh b/relcatalogif/type.hh
new file mode 100644
index 0000000..f119f09
--- /dev/null
+++ b/relcatalogif/type.hh
@@ -0,0 +1,137 @@
+// -*-C++-*- (for Emacs)
+
+/*
+* 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>.
+*/
+/*************************************************************
+ *
+ *
+ * PURPOSE:
+ * The Type class is the superclass for the classes
+ * CollectionType, BaseType, and MDDType.
+ *
+ *
+ * COMMENTS:
+ *
+ ************************************************************/
+
+#ifndef _TYPE_HH_
+#define _TYPE_HH_
+
+class Type;
+class OId;
+
+#include <iostream>
+using std::ostream;
+using std::cout;
+using std::endl;
+
+#include "catalogmgr/ops.hh"
+#include "reladminif/dbnamedobject.hh"
+
+//@ManMemo: Module: {\bf relcatalogif}.
+
+/*@Doc:
+Type is the abstract base class for CollectionType, BaseType, and MDDType.
+
+Common to each type is the ability to get its name.
+This functionality is defined as a pure virtual function here.
+
+{\bf Interdependencies}
+
+Each \Ref{Tile} has a pointer to its BaseType. Pointers to BaseType
+are also used in subclasses of \Ref{MDDObject}.
+*/
+
+class Type : public DBNamedObject
+ {
+ public:
+ virtual void destroy();
+ /*@Doc:
+ does nothing. is neccessary to stop types from being deleted by ~DBRef<Type>
+ */
+
+ /// returns the name of the type as a C string.
+ virtual const char* getTypeName() const;
+ /*@Doc:
+ The name of the type is the class name without the Type suffix.
+ e.g. "Bool" for \Ref{BoolType}, or "ULong" for \Ref{ULongType},
+ or "Set" for \Ref{SetType}, or "Dimension" for \Ref{DimensionType}.
+ */
+
+ /// returns the structure of the type as a C string.
+ virtual char* getTypeStructure() const;
+ /*@Doc:
+ Returns a copy of getTypeName() for non-structured base types. For
+ structured types a list of the elements in the form of #struct {
+ ulong elemName1, ushort elemName2 }# is returned. MDDTypes are
+ printed in the form #marray< RGBPixel, [10:20]# (less information,
+ if domain is not specified). Sets are printed in the form
+ #set<setName>#. The char* has to be freed by the caller!
+ */
+
+ const TypeEnum getType() const;
+ /*@Doc:
+ returns the type as a TypeEnum.
+ */
+
+ virtual int compatibleWith(const Type* aType) const;
+ /*@Doc:
+ checks, if two types are compatible (see also \Ref{MDDType}).
+ */
+
+ Type();
+ /*@Doc:
+ default constructor, cannot be used.
+ */
+
+ Type(const OId& id) throw (r_Error);
+ /*@Doc:
+ */
+
+ Type(const Type& old);
+ /*@Doc:
+ */
+
+ Type& operator=(const Type& old);
+ /*@Doc:
+ */
+
+ virtual ~Type();
+ /*@Doc:
+ virtual destructor.
+ */
+
+ protected:
+ TypeEnum myType;
+ /*@Doc:
+ enum for type. this can be ULONG, USHORT, CHAR,
+ BOOLTYPE, LONG, SHORT, OCTET, DOUBLE,
+ FLOAT, STRUCT, CLASSTYPE, SETTYPE, MDDTYPE
+ */
+
+ Type(const char* name);
+ /*@Doc:
+ */
+ };
+
+#endif
diff --git a/relcatalogif/typeiterator.C b/relcatalogif/typeiterator.C
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/relcatalogif/typeiterator.C
diff --git a/relcatalogif/typeiterator.hh b/relcatalogif/typeiterator.hh
new file mode 100644
index 0000000..a1a3e63
--- /dev/null
+++ b/relcatalogif/typeiterator.hh
@@ -0,0 +1,30 @@
+/*
+* 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>.
+*/
+#ifndef _TYPEITERATOR_HH_
+#define _TYPEITERATOR_HH_
+
+#include "reladminif/dbobjectiterator.hh"
+#define TypeIterator DBObjectIterator
+
+#endif
+
diff --git a/relcatalogif/uintegraltype.hh b/relcatalogif/uintegraltype.hh
new file mode 100644
index 0000000..89a4362
--- /dev/null
+++ b/relcatalogif/uintegraltype.hh
@@ -0,0 +1,90 @@
+/*
+* 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>.
+*/
+/*************************************************************
+ *
+ *
+ * PURPOSE:
+ * The UIntegralType class is the superclass for all unsigned
+ * integral types (Char, Short, Long) describing the type of a
+ * cell
+ *
+ *
+ * COMMENTS:
+ *
+ ************************************************************/
+
+#ifndef _UINTEGRALTYPE_HH_
+#define _UINTEGRALTYPE_HH_
+
+#include "atomictype.hh"
+
+//@ManMemo: Module: {\bf relcatalogif}.
+
+/*@Doc:
+UIntegralType is the abstract base class for all integral
+\Ref{BaseType} subclasses, i.e. base types like \Ref{ULongType} or
+\Ref{BoolType}. It provides conversions to/from long and
+double. It's subclasses must implement conversions to/from unsigned
+long.
+*/
+
+class UIntegralType : public AtomicType {
+public:
+ UIntegralType(unsigned int newSize):
+ AtomicType(newSize) {}
+ /*@Doc:
+ constructor.
+ */
+
+ UIntegralType(const UIntegralType& old):
+ AtomicType(old) {}
+ /*@Doc:
+ copy constructor.
+ */
+
+ UIntegralType(const OId& id) throw (r_Error):
+ AtomicType(id) {}
+ /*@Doc:
+ */
+
+ virtual ~UIntegralType() {}
+ /*@Doc:
+ */
+
+ virtual r_Long* convertToCLong(const char*, r_Long*) const;
+ virtual char* makeFromCLong(char*, const r_Long*) const;
+
+ virtual double* convertToCDouble(const char*, double*) const;
+ virtual char* makeFromCDouble(char*, const double*) const;
+
+protected:
+ UIntegralType(const char* name, unsigned int newSize):
+ AtomicType(name, newSize) {}
+ /*@Doc:
+ */
+
+};
+
+#include "uintegraltype.icc"
+
+#endif
diff --git a/relcatalogif/uintegraltype.icc b/relcatalogif/uintegraltype.icc
new file mode 100644
index 0000000..3bd0a96
--- /dev/null
+++ b/relcatalogif/uintegraltype.icc
@@ -0,0 +1,51 @@
+/*
+* 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>.
+*/
+/*************************************************************
+*
+*
+* COMMENTS:
+*
+************************************************************/
+
+inline r_Long*
+UIntegralType::convertToCLong(const char* cell, r_Long* value) const {
+ return (r_Long*)(this->convertToCULong(cell, (r_ULong *)value));
+}
+
+inline double*
+UIntegralType::convertToCDouble(const char* cell, double* value) const {
+ r_Long tmp;
+ *value = *this->convertToCLong(cell, &tmp);
+ return value;
+}
+
+inline char*
+UIntegralType::makeFromCLong(char* cell, const r_Long* value) const {
+ return this->makeFromCULong(cell, (r_ULong *)value);
+}
+
+inline char*
+UIntegralType::makeFromCDouble(char* cell, const double* value) const {
+ r_Long tmp = *value;
+ return this->makeFromCLong(cell, &tmp);
+}
diff --git a/relcatalogif/ulongtype.C b/relcatalogif/ulongtype.C
new file mode 100644
index 0000000..7f4c91c
--- /dev/null
+++ b/relcatalogif/ulongtype.C
@@ -0,0 +1,149 @@
+/*
+* 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>.
+*/
+/*************************************************************
+ *
+ *
+ * PURPOSE:
+ * uses ODMG-conformant O2 classes
+ *
+ *
+ * COMMENTS:
+ * none
+ *
+ ************************************************************/
+
+static const char rcsid[] = "@(#)catalogif,ULongType: $Header: /home/rasdev/CVS-repository/rasdaman/relcatalogif/ulongtype.C,v 1.10 2003/12/27 23:23:04 rasdev Exp $";
+
+#include "ulongtype.hh"
+#include <iomanip>
+#include <string.h>
+#include "reladminif/externs.h"
+
+ULongType::ULongType(const OId& id) throw (r_Error)
+ : UIntegralType(id)
+ {
+ readFromDb();
+ }
+
+/*************************************************************
+ * Method name...: ULongType();
+ *
+ * Arguments.....: none
+ * Return value..: none
+ * Description...: initializes member variables for an
+ * ULongType.
+ ************************************************************/
+
+ULongType::ULongType()
+ : UIntegralType(ULongType::Name, 4)
+ {
+ myOId = OId(ULONG, OId::ATOMICTYPEOID);
+ myType = ULONG;
+ }
+
+/*************************************************************
+ * Method name...: ULongType(const ULongType& old);
+ *
+ * Arguments.....: none
+ * Return value..: none
+ * Description...: copy constructor
+ ************************************************************/
+
+ULongType::ULongType(const ULongType& old)
+ : UIntegralType(old)
+ {
+ }
+
+/*************************************************************
+ * Method name...: operator=(const ULongType&);
+ *
+ * Arguments.....: none
+ * Return value..: none
+ * Description...: copy constructor
+ ************************************************************/
+
+ULongType& ULongType::operator=(const ULongType& old)
+ {
+ // Gracefully handle self assignment
+ if (this == &old)
+ return *this;
+ AtomicType::operator=(old);
+ return *this;
+ }
+
+/*************************************************************
+ * Method name...: ~ULongType();
+ *
+ * Arguments.....: none
+ * Return value..: none
+ * Description...: virtual destructor
+ ************************************************************/
+
+ULongType::~ULongType()
+{
+}
+
+/*************************************************************
+ * Method name...: void printCell( ostream& stream,
+ * const char* cell )
+ *
+ * Arguments.....:
+ * stream: stream to print on
+ * cell: pointer to cell to print
+ * Return value..: none
+ * Description...: prints a cell cell in hex on stream
+ * followed by a space.
+ * Assumes that ULong is stored MSB..LSB
+ * on HP.
+ ************************************************************/
+
+void
+ULongType::printCell( ostream& stream, const char* cell ) const
+{
+ stream << std::setw(8) << *(r_ULong*)cell;
+}
+
+r_ULong*
+ULongType::convertToCULong(const char* cell, r_ULong* value) const
+{
+ *value = *(r_ULong*)cell;
+ return value;
+}
+
+
+char*
+ULongType::makeFromCULong(char* cell, const r_ULong* value) const
+{
+ *(r_ULong*)(cell) = *value;
+ return cell;
+}
+
+void
+ULongType::readFromDb() throw (r_Error)
+ {
+ setName(ULongType::Name);
+ size = 4;
+ myOId = OId(ULONG, OId::ATOMICTYPEOID);
+ myType = ULONG;
+ }
+
diff --git a/relcatalogif/ulongtype.hh b/relcatalogif/ulongtype.hh
new file mode 100644
index 0000000..5e0b369
--- /dev/null
+++ b/relcatalogif/ulongtype.hh
@@ -0,0 +1,101 @@
+// -*-C++-*- (for Emacs)
+
+/*
+* 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>.
+*/
+/*************************************************************
+ *
+ *
+ * PURPOSE:
+ * The ULongType class is the superclass for all classes
+ * describing the type of a cell
+ *
+ *
+ * COMMENTS:
+ * This file is patched by O2!
+ *
+ ************************************************************/
+
+#ifndef _ULONGTYPE_HH_
+#define _ULONGTYPE_HH_
+
+#include <iostream>
+#include "uintegraltype.hh"
+#include "catalogmgr/ops.hh"
+#include "reladminif/oidif.hh"
+
+//@ManMemo: Module: {\bf relcatalogif}.
+
+/*@Doc:
+ULongType is the base type used for 32bit unsigned integer cell
+values. The value of a ULong is stored in four chars.
+*/
+
+class ULongType : public UIntegralType
+ {
+ public:
+ ULongType(const OId& id) throw (r_Error);
+
+ ULongType();
+ /*@Doc:
+ default constructor, sets type name to "ULong".
+ */
+
+ ULongType(const ULongType& old);
+ /*@Doc:
+ copy constructor.
+ */
+
+ ULongType& operator=(const ULongType& old);
+ /*@Doc:
+ assignment operator.
+ */
+
+ virtual ~ULongType();
+ /*@Doc:
+ virtual destructor.
+ */
+
+ virtual void printCell(ostream& stream, const char* cell) const;
+ /*@Doc:
+ */
+
+ virtual r_ULong* convertToCULong(const char* cell, r_ULong* value) const;
+ /*@Doc:
+ */
+
+ virtual char* makeFromCULong(char* cell, const r_ULong* value) const;
+ /*@Doc:
+ */
+
+ static const char* Name;
+
+ protected:
+
+ virtual void readFromDb() throw (r_Error);
+ /*@Doc:
+ initializes the attributes of this type.
+ there is no database activity. this is hard coded.
+ */
+ };
+
+#endif
diff --git a/relcatalogif/ushorttype.C b/relcatalogif/ushorttype.C
new file mode 100644
index 0000000..f5e068f
--- /dev/null
+++ b/relcatalogif/ushorttype.C
@@ -0,0 +1,155 @@
+/*
+* 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>.
+*/
+/*************************************************************
+ *
+ *
+ * PURPOSE:
+ * uses ODMG-conformant O2 classes
+ *
+ *
+ * COMMENTS:
+ * none
+ *
+ ************************************************************/
+
+static const char rcsid[] = "@(#)catalogif,UShortType: $Header: /home/rasdev/CVS-repository/rasdaman/relcatalogif/ushorttype.C,v 1.9 2003/12/27 23:23:04 rasdev Exp $";
+
+#include "ushorttype.hh"
+#include <iomanip>
+#include <string.h>
+
+/*************************************************************
+ * Method name...: UShortType();
+ *
+ * Arguments.....: none
+ * Return value..: none
+ * Description...: initializes member variables for an
+ * UShortType.
+ ************************************************************/
+
+UShortType::UShortType()
+ : UIntegralType(UShortType::Name, 2)
+ {
+ myType = USHORT;
+ myOId = OId(USHORT, OId::ATOMICTYPEOID);
+ }
+
+/*************************************************************
+ * Method name...: UShortType(const UShortType& old);
+ *
+ * Arguments.....: none
+ * Return value..: none
+ * Description...: copy constructor
+ ************************************************************/
+
+UShortType::UShortType(const UShortType& old)
+ : UIntegralType(old)
+ {
+ }
+
+UShortType::UShortType(const OId& id) throw (r_Error)
+ : UIntegralType(id)
+ {
+ readFromDb();
+ }
+
+/*************************************************************
+ * Method name...: operator=(const UShortType&);
+ *
+ * Arguments.....: none
+ * Return value..: none
+ * Description...: copy constructor
+ ************************************************************/
+
+UShortType& UShortType::operator=(const UShortType& old)
+ {
+ // Gracefully handle self assignment
+ if (this == &old)
+ return *this;
+ AtomicType::operator=(old);
+ return *this;
+ }
+
+/*************************************************************
+ * Method name...: ~UShortType();
+ *
+ * Arguments.....: none
+ * Return value..: none
+ * Description...: virtual destructor
+ ************************************************************/
+
+UShortType::~UShortType()
+{
+}
+
+/*************************************************************
+ * Method name...: void printCell( ostream& stream,
+ * const char* cell )
+ *
+ * Arguments.....:
+ * stream: stream to print on
+ * cell: pointer to cell to print
+ * Return value..: none
+ * Description...: prints a cell cell in hex on stream
+ * followed by a space.
+ * Assumes that UShort is stored MSB..LSB
+ * on HP.
+ ************************************************************/
+
+void
+UShortType::printCell( ostream& stream, const char* cell ) const
+{
+ // !!!! HP specific, assumes 4 Byte long and MSB..LSB
+ // byte order
+ stream << std::setw(5) << *(unsigned short*)cell;
+}
+
+r_ULong*
+UShortType::convertToCULong(const char* cell, r_ULong* value) const
+{
+ // !!!! HP specific, assumes 2 Byte short
+ *value = *(unsigned short*)cell;
+ return value;
+}
+
+
+char*
+UShortType::makeFromCULong(char* cell, const r_ULong* value) const
+{
+ r_ULong myLong = *value;
+ // restricting long to value range of short
+ myLong = myLong > USHRT_MAX ? USHRT_MAX : myLong;
+ myLong = myLong < 0 ? 0 : myLong;
+ // !!!! HP specific, assumes 2 Byte short
+ *(unsigned short*)(cell) = (unsigned short)myLong;
+ return cell;
+}
+
+void
+UShortType::readFromDb() throw (r_Error)
+ {
+ size = 2;
+ setName(UShortType::Name);
+ myType = USHORT;
+ myOId = OId(USHORT, OId::ATOMICTYPEOID);
+ }
diff --git a/relcatalogif/ushorttype.hh b/relcatalogif/ushorttype.hh
new file mode 100644
index 0000000..39f614f
--- /dev/null
+++ b/relcatalogif/ushorttype.hh
@@ -0,0 +1,100 @@
+// -*-C++-*- (for Emacs)
+
+/*
+* 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>.
+*/
+/*************************************************************
+ *
+ *
+ * PURPOSE:
+ * The UShortType class is the superclass for all classes
+ * describing the type of a cell
+ *
+ *
+ * COMMENTS:
+ * This file is patched by O2!
+ *
+ ************************************************************/
+
+#ifndef _USHORTTYPE_HH_
+#define _USHORTTYPE_HH_
+
+#include <iostream>
+#include "uintegraltype.hh"
+#include "catalogmgr/ops.hh"
+
+//@ManMemo: Module: {\bf relcatalogif}.
+
+/*@Doc:
+UShortType is the base type used for 16bit unsigned integer cell
+values. The value of a UShort is stored in four chars.
+*/
+
+class UShortType : public UIntegralType
+ {
+ public:
+ UShortType(const OId& id) throw (r_Error);
+
+ UShortType();
+ /*@Doc:
+ default constructor, sets type name to "UShort".
+ */
+
+ UShortType(const UShortType& old);
+ /*@Doc:
+ copy constructor.
+ */
+
+ UShortType& operator=(const UShortType& old);
+ /*@Doc:
+ assignment operator.
+ */
+
+ virtual ~UShortType();
+ /*@Doc:
+ virtual destructor.
+ */
+
+ virtual void printCell(ostream& stream, const char* cell) const;
+ /*@Doc:
+ */
+
+ virtual r_ULong* convertToCULong(const char* cell, r_ULong* value) const;
+ /*@Doc:
+ */
+
+ virtual char* makeFromCULong(char* cell, const r_ULong* value) const;
+ /*@Doc:
+ */
+
+ static const char* Name;
+
+ protected:
+
+ virtual void readFromDb() throw (r_Error);
+ /*@Doc:
+ initializes the attributes of this type.
+ there is no database activity. this is hard coded.
+ */
+ };
+
+#endif