summaryrefslogtreecommitdiffstats
path: root/manuals_and_examples/examples/c++
diff options
context:
space:
mode:
Diffstat (limited to 'manuals_and_examples/examples/c++')
-rw-r--r--manuals_and_examples/examples/c++/Makefile165
-rw-r--r--manuals_and_examples/examples/c++/avg-cell-red.cc144
-rw-r--r--manuals_and_examples/examples/c++/avg-cell.cc136
-rw-r--r--manuals_and_examples/examples/c++/basictypes.hh206
-rw-r--r--manuals_and_examples/examples/c++/lookup.cc146
-rw-r--r--manuals_and_examples/examples/c++/query.cc172
-rw-r--r--manuals_and_examples/examples/c++/query2.cc181
7 files changed, 1150 insertions, 0 deletions
diff --git a/manuals_and_examples/examples/c++/Makefile b/manuals_and_examples/examples/c++/Makefile
new file mode 100644
index 0000000..3a23dd1
--- /dev/null
+++ b/manuals_and_examples/examples/c++/Makefile
@@ -0,0 +1,165 @@
+# -*-Makefile-*-
+#
+# 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>. # Top Level makefile. This points to the various modules that have to be build
+# and/or deployed
+#
+# MAKEFILE FOR:
+# Compile and link example C++ programs;
+# right now, works only with GNU Make!
+#
+#
+##################################################################
+
+
+######################### Definitions ############################
+
+# choose C++ compiler
+ifeq ($(OSTYPE),linux)
+OSTYPE=linux-gnu
+endif
+ifeq ($(OSTYPE),Linux)
+OSTYPE=linux-gnu
+endif
+
+ifneq ($(OSTYPE),linux-gnu)
+endif
+ifneq ($(OSTYPE),linux-gnu)
+CXX = CC
+else
+CXX = g++
+endif
+
+# RasDaMan central includes
+CXXFLAGS = -I$(RMANHOME)/include
+
+ifeq ($(OSTYPE),solaris)
+
+ CXXFLAGS += -DSOLARIS
+
+ # enable exception handling
+ # exceptions are supported by default
+
+ # use ANSI C
+ # is used by default
+
+else
+ifeq ($(OSTYPE),linux-gnu)
+
+ CXXFLAGS += -DLINUX -DEARLY_TEMPLATE
+
+ # enable exception handling
+ # exceptions are supported by default
+
+ # use ANSI C
+ # is used by default
+
+else
+
+ CXXFLAGS += -DHPUX
+
+ # enable exception handling
+ CXXFLAGS += +eh
+
+ # use ANSI C
+ CXXFLAGS += +a1
+
+ # necessary for templates because of bug in nm
+ CXXFLAGS += -ptb
+
+endif
+endif
+
+ifeq ($(OSTYPE),solaris)
+ LDFLAGS += -lmalloc -lsocket -lnsl
+endif
+
+# add communication flags
+CXXFLAGS += -DONCRPC
+
+# pre-installed exchange format libraries needed
+FMTLIBS = /usr/lib/libnetpbm.a /usr/lib/libjpeg.a /usr/local/lib/libpng.a /usr/local/lib/libtiff.a
+
+# libraries needed for linkage (in particular: rasdaman + exchange formats)
+LIBS += -L/usr/lib -L$(RMANHOME)/lib \
+ -lclientcomm -lrasodmg -lcompression -lconversion -lclientcomm -lrasodmg -lraslib \
+ -lppm -lpgm -lnetpbm -ljpeg -lpng -ltiff -lmfhdf -ldf -lcrypto \
+ -lm -lz
+
+
+########################### Targets ##############################
+
+# this global target first checks for required libraries
+# disable target 'check' if you don't want this to be run
+all: check avg-cell avg-cell-red lookup query insertppm
+
+# check whether exchange format libraries have been installed
+.PHONY: check
+check:
+ @for lib in $(FMTLIBS); \
+ do \
+ if [[ ! -f $$lib ]]; \
+ then \
+ echo "error: cannot find required library $$lib - package not installed?"; \
+ fi \
+ done
+
+avg-cell: avg-cell.o
+ $(CXX) $(LDFLAGS) -o $@ $^ $(LIBS)
+
+avg-cell-red: avg-cell-red.o
+ $(CXX) $(LDFLAGS) -o $@ $^ $(LIBS)
+
+lookup: lookup.o
+ $(CXX) $(LDFLAGS) -o $@ $^ $(LIBS)
+
+query: query.o
+ $(CXX) $(LDFLAGS) -o $@ $^ $(LIBS)
+
+insertppm: insertppm.o
+ $(CXX) $(LDFLAGS) -o $@ $^ $(LIBS)
+
+.PHONY : clean
+clean:
+ -rm *.o *.log *.dbg *.bm
+ -rm query insertppm lookup avg-cell avg-cell-red
+ifeq ($(OSTYPE),solaris)
+ cd $(RMANHOME)/include/rasodmg/ptrepository; ptclean
+else
+ifneq ($(OSTYPE),linux-gnu)
+ -rm -R $(RMANHOME)/include/rasodmg/ptrepository/*
+endif
+endif
+
+######################## Dependencies ############################
+
+avg-cell.o: avg-cell.cc
+
+avg-cell-red.o: avg-cell-red.cc
+
+lookup.o: lookup.cc
+
+query.o: query.cc
+
+insertppm.o: insertppm.cc
+ $(CXX) $(CXXFLAGS) -c insertppm.cc -I/usr/X11R6/include
+
+# end of Makefile
diff --git a/manuals_and_examples/examples/c++/avg-cell-red.cc b/manuals_and_examples/examples/c++/avg-cell-red.cc
new file mode 100644
index 0000000..4896a83
--- /dev/null
+++ b/manuals_and_examples/examples/c++/avg-cell-red.cc
@@ -0,0 +1,144 @@
+/*
+* 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:
+ * Example program for computing the avg cell value
+ * for each image in a given 2-D RGB collection.
+ *
+ *
+ ************************************************************/
+
+#include <iostream>
+
+// Linux needs this for template instantiation
+#ifdef EARLY_TEMPLATE
+#define __EXECUTABLE__
+#ifdef __GNUG__
+#include "raslib/template_inst.hh"
+#endif
+#endif
+
+
+// rasdl generated data type file:
+// (contains predefined RGB pixel structure)
+#include "basictypes.hh"
+
+
+int main( int ac, char** av )
+{
+ char rasmgrName[255];
+ int rasmgrPort;
+ char baseName[255];
+ char collName[255];
+ char userName[255];
+ char userPass[255];
+
+ double sum;
+
+ if( ac != 7 )
+ {
+ cout << "Usage: avg-cell-red rasmgr_name rasmgr_port base_name collection_name user_name user_passwd" << endl;
+ return -1;
+ }
+
+ strcpy( rasmgrName, av[1] );
+ rasmgrPort = strtoul( av[2], NULL, 0);
+ strcpy( baseName, av[3] );
+ strcpy( collName, av[4] );
+ strcpy( userName, av[5] );
+ strcpy( userPass, av[6] );
+
+ r_Database database;
+ r_Transaction transaction;
+ r_Ref< r_Set< r_Ref< r_Marray< RGBPixel > > > > image_set;
+ r_Iterator< r_Ref< r_Marray< RGBPixel > > > iter;
+ r_Ref< r_Marray< RGBPixel > > image;
+ r_Range i,j;
+ long pixelcount;
+
+ try
+ {
+ database.set_servername( rasmgrName, rasmgrPort );
+ database.set_useridentification( userName, userPass );
+
+ cout << "Opening database " << baseName
+ << " on " << rasmgrName << "... " << flush;
+ database.open( baseName );
+ cout << "OK" << endl;
+
+ cout << "Starting read-only transaction ... " << flush;
+ transaction.begin( r_Transaction::read_only );
+ cout << "OK" << endl;
+
+ cout << "Looking up collection " << collName << " ..." << flush;
+ image_set = database.lookup_object( collName );
+ cout << "OK" << endl;
+
+ cout << "Collection contains " << image_set->cardinality()
+ << " entries" << endl;
+
+ iter = image_set->create_iterator();
+ for( iter.reset(); iter.not_done(); iter++ )
+ {
+ RGBPixel pixel;
+ image = *iter;
+ sum = 0.0;
+ for ( i=image->spatial_domain()[0].low(); i<=image->spatial_domain()[0].high(); i++ )
+ {
+ for ( j=image->spatial_domain()[1].low(); j<=image->spatial_domain()[1].high(); j++ )
+ {
+ pixel = (*image)[ r_Point(i,j) ];
+ sum += pixel.red;
+ }
+ }
+ pixelcount =
+ ( image->spatial_domain()[0].high() - image->spatial_domain()[0].low() + 1 )
+ * ( image->spatial_domain()[1].high() - image->spatial_domain()[1].low() + 1 );
+ cout << " avg over " << pixelcount
+ << " red pixels is "
+ << sum / pixelcount
+ << endl << flush;
+ }
+
+ cout << "Committing transaction ... " << flush;
+ transaction.commit();
+ cout << "OK" << endl;
+
+ cout << "Closing database ... " << flush;
+ database.close();
+ cout << "OK" << endl;
+ }
+ catch( r_Error& errorObj )
+ {
+ cerr << errorObj.what() << endl;
+ return -1;
+ }
+
+ return 0;
+}
+
+/*
+ * end of avg-cell-red.cc
+ */
diff --git a/manuals_and_examples/examples/c++/avg-cell.cc b/manuals_and_examples/examples/c++/avg-cell.cc
new file mode 100644
index 0000000..c0012e1
--- /dev/null
+++ b/manuals_and_examples/examples/c++/avg-cell.cc
@@ -0,0 +1,136 @@
+/*
+* 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:
+ * Example program for computing the avg cell value
+ * for each n-D 8-bit grey image in a given collection.
+ *
+ *
+ ************************************************************/
+
+#include <iostream>
+
+// Linux needs this for template instantiation
+#ifdef EARLY_TEMPLATE
+#define __EXECUTABLE__
+#ifdef __GNUG__
+#include "raslib/template_inst.hh"
+#endif
+#endif
+
+// rasdl generated data type file:
+// (contains predefined RGBPixel structure)
+#include "basictypes.hh"
+
+
+int main( int ac, char** av )
+{
+ char rasmgrName[255];
+ int rasmgrPort;
+ char baseName[255];
+ char collName[255];
+ char userName[255];
+ char userPass[255];
+ r_Base_Type *celltype;
+ double sum;
+
+ if( ac != 7 )
+ {
+ cout << "Usage: avg-cell rasmgr_name rasmgr_port base_name collection_name user_name user_passwd" << endl;
+ return -1;
+ }
+
+ strcpy( rasmgrName, av[1] );
+ rasmgrPort = strtoul( av[2], NULL, 0);
+ strcpy( baseName, av[3] );
+ strcpy( collName, av[4] );
+ strcpy( userName, av[5] );
+ strcpy( userPass, av[6] );
+
+ r_Database database;
+ r_Transaction transaction;
+ r_Ref< r_Set< r_Ref< r_Marray< RGBPixel > > > > image_set;
+ r_Iterator< r_Ref< r_Marray< RGBPixel > > > iter;
+ r_Ref< r_Marray< RGBPixel > > image;
+ r_Range i;
+
+ try
+ {
+ database.set_servername( rasmgrName, rasmgrPort );
+ database.set_useridentification( userName, userPass );
+
+ cout << "Opening database " << baseName
+ << " on " << rasmgrName << "... " << flush;
+ database.open( baseName );
+ cout << "OK" << endl;
+
+ cout << "Starting read-only transaction ... " << flush;
+ transaction.begin( r_Transaction::read_only );
+ cout << "OK" << endl;
+
+ cout << "Looking up collection " << collName << " ..." << flush;
+ image_set = database.lookup_object( collName );
+ cout << "OK" << endl;
+
+ cout << "Collection contains " << image_set->cardinality()
+ << " entries" << endl;
+
+ iter = image_set->create_iterator();
+ for( iter.reset(); iter.not_done(); iter++ )
+ {
+ image = *iter;
+ if ( image->get_type_length() != 1 )
+ cout << "skipping image because of non-int cell type" << endl;
+ else
+ {
+ unsigned char *pixelfield = (unsigned char*) image->get_array();
+ sum = 0.0;
+ for ( i=0; i < image->get_array_size(); i++ )
+ sum += pixelfield[i];
+ cout << " avg over " << image->get_array_size()
+ << " pixels is " << sum/image->get_array_size() << endl;
+ }
+ }
+
+ cout << "Committing transaction ... " << flush;
+ transaction.commit();
+ cout << "OK" << endl;
+
+ cout << "Closing database ... " << flush;
+ database.close();
+ cout << "OK" << endl;
+ }
+ catch( r_Error& errorObj )
+ {
+ cerr << errorObj.what() << endl;
+ return -1;
+ }
+
+ return 0;
+}
+
+/*
+ * end of avg-cell.cc
+ */
diff --git a/manuals_and_examples/examples/c++/basictypes.hh b/manuals_and_examples/examples/c++/basictypes.hh
new file mode 100644
index 0000000..adbda31
--- /dev/null
+++ b/manuals_and_examples/examples/c++/basictypes.hh
@@ -0,0 +1,206 @@
+/*
+* 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 file is created automatically by the rasdl processor.
+//
+// DO NOT EDIT
+//------------------------------------------------------------
+
+#ifndef __BASICTYPES_HH_
+#define __BASICTYPES_HH_
+
+//------------------------------------------------------------
+// Includes
+//------------------------------------------------------------
+
+#include "rasdaman.hh"
+
+/*[2,25]*//* TYPEDEF ------------------------- GreyImage */
+typedef r_Marray<r_Char> GreyImage;
+
+/*[3,24]*//* TYPEDEF ------------------------- GreySet */
+typedef r_Set<r_Ref<GreyImage> > GreySet;
+
+/*[6,28]*//* TYPEDEF ------------------------- BoolImage */
+typedef r_Marray<r_Boolean> BoolImage;
+
+/*[7,24]*//* TYPEDEF ------------------------- BoolSet */
+typedef r_Set<r_Ref<BoolImage> > BoolSet;
+
+/*[10,1]*//* STRUCT -------------------------- RGBPixel */
+struct RGBPixel {
+ r_Char red;
+ r_Char green;
+ r_Char blue;
+};
+/*[11,29]*//* TYPEDEF ------------------------- RGBImage */
+typedef r_Marray<RGBPixel> RGBImage;
+
+/*[12,23]*//* TYPEDEF ------------------------- RGBSet */
+typedef r_Set<r_Ref<RGBImage> > RGBSet;
+
+/*[15,35]*//* TYPEDEF ------------------------- ULongImage */
+typedef r_Marray<r_ULong > ULongImage;
+
+/*[16,25]*//* TYPEDEF ------------------------- ULongSet */
+typedef r_Set<r_Ref<ULongImage> > ULongSet;
+
+/*[19,26]*//* TYPEDEF ------------------------- GreyCube */
+typedef r_Marray<r_Char> GreyCube;
+
+/*[20,23]*//* TYPEDEF ------------------------- GreySet3 */
+typedef r_Set<r_Ref<GreyCube> > GreySet3;
+
+/*[24,29]*//* TYPEDEF ------------------------- BoolString */
+typedef r_Marray<r_Boolean> BoolString;
+
+/*[25,25]*//* TYPEDEF ------------------------- BoolSet1 */
+typedef r_Set<r_Ref<BoolString> > BoolSet1;
+
+/*[27,29]*//* TYPEDEF ------------------------- BoolCube */
+typedef r_Marray<r_Boolean> BoolCube;
+
+/*[28,23]*//* TYPEDEF ------------------------- BoolSet3 */
+typedef r_Set<r_Ref<BoolCube> > BoolSet3;
+
+/*[30,26]*//* TYPEDEF ------------------------- GreyString */
+typedef r_Marray<r_Char> GreyString;
+
+/*[31,25]*//* TYPEDEF ------------------------- GreySet1 */
+typedef r_Set<r_Ref<GreyString> > GreySet1;
+
+/*[33,27]*//* TYPEDEF ------------------------- ShortString */
+typedef r_Marray<r_Short > ShortString;
+
+/*[34,26]*//* TYPEDEF ------------------------- ShortSet1 */
+typedef r_Set<r_Ref<ShortString> > ShortSet1;
+
+/*[36,27]*//* TYPEDEF ------------------------- ShortImage */
+typedef r_Marray<r_Short > ShortImage;
+
+/*[37,25]*//* TYPEDEF ------------------------- ShortSet */
+typedef r_Set<r_Ref<ShortImage> > ShortSet;
+
+/*[39,27]*//* TYPEDEF ------------------------- ShortCube */
+typedef r_Marray<r_Short > ShortCube;
+
+/*[40,24]*//* TYPEDEF ------------------------- ShortSet3 */
+typedef r_Set<r_Ref<ShortCube> > ShortSet3;
+
+/*[42,36]*//* TYPEDEF ------------------------- UShortString */
+typedef r_Marray<r_UShort > UShortString;
+
+/*[43,27]*//* TYPEDEF ------------------------- UShortSet1 */
+typedef r_Set<r_Ref<UShortString> > UShortSet1;
+
+/*[45,36]*//* TYPEDEF ------------------------- UShortImage */
+typedef r_Marray<r_UShort > UShortImage;
+
+/*[46,26]*//* TYPEDEF ------------------------- UShortSet */
+typedef r_Set<r_Ref<UShortImage> > UShortSet;
+
+/*[48,36]*//* TYPEDEF ------------------------- UShortCube */
+typedef r_Marray<r_UShort > UShortCube;
+
+/*[49,25]*//* TYPEDEF ------------------------- UShortSet3 */
+typedef r_Set<r_Ref<UShortCube> > UShortSet3;
+
+/*[51,26]*//* TYPEDEF ------------------------- LongString */
+typedef r_Marray<r_Long > LongString;
+
+/*[52,25]*//* TYPEDEF ------------------------- LongSet1 */
+typedef r_Set<r_Ref<LongString> > LongSet1;
+
+/*[54,26]*//* TYPEDEF ------------------------- LongImage */
+typedef r_Marray<r_Long > LongImage;
+
+/*[55,24]*//* TYPEDEF ------------------------- LongSet */
+typedef r_Set<r_Ref<LongImage> > LongSet;
+
+/*[57,26]*//* TYPEDEF ------------------------- LongCube */
+typedef r_Marray<r_Long > LongCube;
+
+/*[58,23]*//* TYPEDEF ------------------------- LongSet3 */
+typedef r_Set<r_Ref<LongCube> > LongSet3;
+
+/*[60,35]*//* TYPEDEF ------------------------- ULongString */
+typedef r_Marray<r_ULong > ULongString;
+
+/*[61,26]*//* TYPEDEF ------------------------- ULongSet1 */
+typedef r_Set<r_Ref<ULongString> > ULongSet1;
+
+/*[63,35]*//* TYPEDEF ------------------------- ULongCube */
+typedef r_Marray<r_ULong > ULongCube;
+
+/*[64,24]*//* TYPEDEF ------------------------- ULongSet3 */
+typedef r_Set<r_Ref<ULongCube> > ULongSet3;
+
+/*[66,30]*//* TYPEDEF ------------------------- RGBString */
+typedef r_Marray<RGBPixel> RGBString;
+
+/*[67,24]*//* TYPEDEF ------------------------- RGBSet1 */
+typedef r_Set<r_Ref<RGBString> > RGBSet1;
+
+/*[69,30]*//* TYPEDEF ------------------------- RGBCube */
+typedef r_Marray<RGBPixel> RGBCube;
+
+/*[70,22]*//* TYPEDEF ------------------------- RGBSet3 */
+typedef r_Set<r_Ref<RGBCube> > RGBSet3;
+
+/*[72,27]*//* TYPEDEF ------------------------- FloatString */
+typedef r_Marray<r_Float> FloatString;
+
+/*[73,26]*//* TYPEDEF ------------------------- FloatSet1 */
+typedef r_Set<r_Ref<FloatString> > FloatSet1;
+
+/*[75,27]*//* TYPEDEF ------------------------- FloatImage */
+typedef r_Marray<r_Float> FloatImage;
+
+/*[76,25]*//* TYPEDEF ------------------------- FloatSet */
+typedef r_Set<r_Ref<FloatImage> > FloatSet;
+
+/*[78,27]*//* TYPEDEF ------------------------- FloatCube */
+typedef r_Marray<r_Float> FloatCube;
+
+/*[79,24]*//* TYPEDEF ------------------------- FloatSet3 */
+typedef r_Set<r_Ref<FloatCube> > FloatSet3;
+
+/*[81,28]*//* TYPEDEF ------------------------- DoubleString */
+typedef r_Marray<r_Double> DoubleString;
+
+/*[82,27]*//* TYPEDEF ------------------------- DoubleSet1 */
+typedef r_Set<r_Ref<DoubleString> > DoubleSet1;
+
+/*[84,28]*//* TYPEDEF ------------------------- DoubleImage */
+typedef r_Marray<r_Double> DoubleImage;
+
+/*[85,26]*//* TYPEDEF ------------------------- DoubleSet */
+typedef r_Set<r_Ref<DoubleImage> > DoubleSet;
+
+/*[87,28]*//* TYPEDEF ------------------------- DoubleCube */
+typedef r_Marray<r_Double> DoubleCube;
+
+/*[88,25]*//* TYPEDEF ------------------------- DoubleSet3 */
+typedef r_Set<r_Ref<DoubleCube> > DoubleSet3;
+
+#endif
diff --git a/manuals_and_examples/examples/c++/lookup.cc b/manuals_and_examples/examples/c++/lookup.cc
new file mode 100644
index 0000000..b4817fa
--- /dev/null
+++ b/manuals_and_examples/examples/c++/lookup.cc
@@ -0,0 +1,146 @@
+/*
+* 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:
+ * Example program for looking up the content of a collection.
+ *
+ *
+ ************************************************************/
+
+#include <iostream>
+
+// Linux needs this for template instantiation
+#ifdef EARLY_TEMPLATE
+#define __EXECUTABLE__
+#ifdef __GNUG__
+#include "raslib/template_inst.hh"
+#endif
+#endif
+
+
+// this file is generated by the rasdl processor
+#include "basictypes.hh"
+
+
+int main( int ac, char** av )
+{
+ char rasmgrName[255];
+ int rasmgrPort;
+ char baseName[255];
+ char collName[255];
+ char userName[255];
+ char userPass[255];
+
+ if( ac != 7 )
+ {
+ cout << "Usage: lookup rasmgr_name rasmgr_port base_name collection_name user_name user_passwd" << endl;
+ return -1;
+ }
+
+ strcpy( rasmgrName, av[1] );
+ rasmgrPort = strtoul( av[2], NULL, 0);
+ strcpy( baseName, av[3] );
+ strcpy( collName, av[4] );
+ strcpy( userName, av[5] );
+ strcpy( userPass, av[6] );
+
+ r_Database database;
+ r_Transaction transaction;
+ r_Ref< r_Set< r_Ref< r_GMarray > > > image_set;
+ r_Ref< r_GMarray > image;
+ r_Iterator< r_Ref< r_GMarray > > iter;
+ int i;
+
+ try
+ {
+ database.set_servername( rasmgrName, rasmgrPort );
+ database.set_useridentification( userName, userPass );
+
+ cout << "Opening database " << baseName
+ << " on " << rasmgrName << "... " << flush;
+
+ database.open( baseName );
+ cout << "OK" << endl;
+
+ cout << "Starting read-only transaction ... " << flush;
+ transaction.begin( r_Transaction::read_only );
+ cout << "OK" << endl;
+
+ cout << "Looking up collection " << collName << " ..." << flush;
+ image_set = database.lookup_object( collName );
+ cout << "OK" << endl;
+
+ cout << "Collection" << endl;
+ cout << " oid...................: " << image_set->get_oid() << endl;
+ cout << " type name.............: " << image_set->get_object_name() << endl;
+ cout << " type structure........: "
+ << ( image_set->get_type_structure() ? image_set->get_type_structure() : "<nn>" )
+ << endl;
+
+ cout << " type schema...........: " << flush;
+ if( image_set->get_type_schema() )
+ image_set->get_type_schema()->print_status( cout );
+ else
+ cout << "<nn>" << flush;
+ cout << endl;
+ cout << " number of entries.....: " << image_set->cardinality() << endl;
+
+ cout << " Element type schema...: " << flush;
+ if( image_set->get_element_type_schema() )
+ image_set->get_element_type_schema()->print_status( cout );
+ else
+ cout << "<nn>" << flush;
+ cout << endl << endl;
+
+ iter = image_set->create_iterator();
+ for( i=1, iter.reset(); iter.not_done(); iter++, i++ )
+ {
+ cout << "Image " << i << endl;
+ image = *iter;
+ image->print_status( cout );
+ cout << endl;
+ }
+ cout << endl;
+
+ cout << "Committing transaction ... " << flush;
+ transaction.commit();
+ cout << "OK" << endl;
+
+ cout << "Closing database ... " << flush;
+ database.close();
+ cout << "OK" << endl;
+ }
+ catch( r_Error& errorObj )
+ {
+ cerr << errorObj.what() << endl;
+ return -1;
+ }
+
+ return 0;
+}
+
+/*
+ * end of lookup.cc
+ */
diff --git a/manuals_and_examples/examples/c++/query.cc b/manuals_and_examples/examples/c++/query.cc
new file mode 100644
index 0000000..9bcf16e
--- /dev/null
+++ b/manuals_and_examples/examples/c++/query.cc
@@ -0,0 +1,172 @@
+/*
+* 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:
+ * Example program for RasML query invocation from C++.
+ *
+ *
+ ************************************************************/
+
+#include <iostream>
+
+// Linux needs this for template instantiation
+#ifdef EARLY_TEMPLATE
+#define __EXECUTABLE__
+#ifdef __GNUG__
+#include "raslib/template_inst.hh"
+#endif
+#endif
+
+// this file is generated by the rasdl processor
+#include "basictypes.hh"
+
+
+int main( int ac, char** av )
+{
+ char rasmgrName[255];
+ int rasmgrPort;
+ char baseName[255];
+ char collName[255];
+ char userName[255];
+ char userPass[255];
+
+ if( ac != 7 )
+ {
+ cout << "Usage: query rasmgr_name rasmgr_port base_name collection_name user_name user_passwd" << endl;
+ return -1;
+ }
+
+ strcpy( rasmgrName, av[1] );
+ rasmgrPort = strtoul( av[2], NULL, 0);
+ strcpy( baseName, av[3] );
+ strcpy( collName, av[4] );
+ strcpy( userName, av[5] );
+ strcpy( userPass, av[6] );
+
+ r_Minterval select_domain = r_Minterval("[0:4,0:4]");
+ r_Minterval where_domain = r_Minterval("[8:9,8:9]");
+ r_ULong threshold_value = 10;
+
+ r_Database database;
+ r_Transaction transaction;
+ r_Set< r_Ref< r_GMarray > > image_set;
+ r_Ref< r_GMarray > image;
+ r_Iterator< r_Ref< r_GMarray > > iter;
+
+ try
+ {
+ database.set_servername( rasmgrName, rasmgrPort );
+ database.set_useridentification( userName, userPass );
+
+ cout << "Opening database " << baseName
+ << " on " << rasmgrName << "... " << flush;
+
+ database.open( baseName );
+ cout << "OK" << endl;
+
+ cout << "Starting read-only transaction ... " << flush;
+ transaction.begin( r_Transaction::read_only );
+ cout << "OK" << endl;
+
+ cout << "Creating the query object ..." << flush;
+ r_OQL_Query query("select a$1 from $2 as a where some_cells( a$3 > $4 )");
+ cout << "OK, Query string is: " << query.get_query() << endl;
+
+ cout << "Substituting query parameters ..." << flush;
+ query << select_domain << collName << where_domain << threshold_value;
+ cout << "OK, Query string is: " << query.get_query() << endl;
+
+ cout << "Executing the query ..." << flush;
+ try
+ {
+ r_oql_execute( query, image_set );
+ }
+ catch( r_Error& errorObj )
+ {
+ cout << "FAILED" << endl << errorObj.what() << endl;
+
+ cout << "Aborting transaction ... " << flush;
+ transaction.abort();
+ cout << "OK" << endl;
+
+ cout << "Closing database ... " << flush;
+ database.close();
+ cout << "OK" << endl;
+ return -1;
+ }
+ cout << "OK" << endl << endl;
+
+ cout << "Collection" << endl;
+ cout << " Oid...................: " << image_set.get_oid() << endl;
+ cout << " Type Name.............: " << image_set.get_object_name() << endl;
+ cout << " Type Structure........: "
+ << ( image_set.get_type_structure() ? image_set.get_type_structure() : "<nn>" )
+ << endl;
+ cout << " Type Schema...........: " << flush;
+ if( image_set.get_type_schema() )
+ image_set.get_type_schema()->print_status( cout );
+ else
+ cout << "<nn>" << flush;
+ cout << endl;
+ cout << " Number of entries.....: " << image_set.cardinality() << endl;
+ cout << " Element Type Schema...: " << flush;
+ if( image_set.get_element_type_schema() )
+ image_set.get_element_type_schema()->print_status( cout );
+ else
+ cout << "<nn>" << flush;
+ cout << endl << endl;
+
+ iter = image_set.create_iterator();
+
+ int i;
+ for ( i=1, iter.reset(); iter.not_done(); iter++, i++ )
+ {
+ cout << "Image " << i << endl;
+ image= *iter;
+ image->print_status( cout );
+ cout << endl;
+ }
+ cout << endl;
+
+ cout << "Committing transaction ... " << flush;
+ transaction.commit();
+ cout << "OK" << endl;
+
+ cout << "Closing database ... " << flush;
+ database.close();
+ cout << "OK" << endl;
+ }
+ catch( r_Error& errorObj )
+ {
+ cerr << errorObj.what() << endl;
+ return -1;
+ }
+
+ return 0;
+}
+
+/*
+ * end of query.cc
+ */
diff --git a/manuals_and_examples/examples/c++/query2.cc b/manuals_and_examples/examples/c++/query2.cc
new file mode 100644
index 0000000..6388e78
--- /dev/null
+++ b/manuals_and_examples/examples/c++/query2.cc
@@ -0,0 +1,181 @@
+/*
+* 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:
+ * Example program for rasql query invocation from C++, showing a
+ * typical mapping scenario.
+ *
+ *
+ * BUGS:
+ * - needs this link cmd line
+ * query2: query2.o
+ * $(CXX) $(LDFLAGS) -o $@ $^ \
+ * -L$(RMANHOME)/lib -lrasodmg -lclientcomm -lcompression -lconversion -lraslib -lnetwork -ljpeg -lpng -ltiff -lmfhdf -ldf -lcrypt o -lclientcomm -lm -lz
+ *
+ ************************************************************/
+
+#include <iostream>
+
+// Linux needs this for template instantiation
+#ifdef EARLY_TEMPLATE
+#define __EXECUTABLE__
+#ifdef __GNUG__
+#include "raslib/template_inst.hh"
+#endif
+#endif
+
+// this file is generated by the rasdl processor
+#include "basictypes.hh"
+
+// connectivity constants
+char *host = "localhost";
+int port = 7001;
+char *db = "RASBASE";
+char *userName = "rasguest";
+char *userPass = "rasguest";
+
+// demo program settings
+// - collection ("map") name
+char *collection = "rgb";
+// - coordinates of map bbox to be retrieved
+unsigned int xImageLo = 100;
+unsigned int xImageHi = 200;
+unsigned int yImageLo = 100;
+unsigned int yImageHi = 200;
+// - target window size
+unsigned int xSize = 10;
+unsigned int ySize = 10;
+
+// global connection objects
+r_Database database;
+r_Transaction transaction;
+
+// sample image accessing function, typical for mapping applications
+// input: collection ("map") name, source image coordinates, target window size
+// output: ptr to image array
+// precondition: we're accessing an RGB image, so that we can select the "green" channel of it
+// note: the most important parts contain markups at the beginning of the line
+unsigned char *readImage( const char *collection, int xImageLo, int xImageHi, int yImageLo, int yImageHi, int xSize, int ySize ) throw (r_Error)
+{
+ r_Set< r_Ref< r_GMarray > > imageSet; // result set
+ r_Ref< r_GMarray > image;
+ r_Iterator< r_Ref< r_GMarray > > iter;
+
+ // function result
+ unsigned char *result = NULL;
+
+ try
+ {
+ cout << "creating query..." << flush;
+ // parameters:
+ // $1 map bbox coordinate, lower x
+ // $2 map bbox coordinate, upper x
+ // $3 map bbox coordinate, lower y
+ // $4 map bbox coordinate, upper y
+ // $5 result window x size
+ // $6 result window y size
+ // $7 collection (i.e., map) name
+/* 1 */ r_OQL_Query query("select scale(img.green[$1:$2,$3:$4],[1:$5,1:$6]) from $7 as img");
+
+ cout << "substituting parameters ..." << flush;
+/* 2 */ query << xImageLo << xImageHi << yImageLo << yImageHi << xSize << ySize << collection;
+ cout << "[query: " << query.get_query() << "]...";
+
+ cout << "executing query..." << flush;
+/* 3 */ r_oql_execute( query, imageSet );
+
+ // now we assume a result has come back
+ iter = imageSet.create_iterator();
+ iter.reset();
+/* 4 */ result = (unsigned char*) (*iter)->get_array();
+
+ }
+ catch(r_Error& e)
+ {
+ cout << "Error: query failed: " << e.what() << flush;
+ throw;
+ }
+
+ return result;
+}
+
+// simple wrapper, handling db connectivity and demo output
+int main()
+{
+ try
+ {
+ database.set_servername( host, port );
+ database.set_useridentification( userName, userPass );
+
+ cout << "Opening database " << db << " on " << host << "..." << flush;
+ database.open( db );
+
+ cout << "starting read-only transaction..." << flush;
+ transaction.begin( r_Transaction::read_only );
+
+ // the real workhorse: fetch image data
+ unsigned char *imgPtr = readImage( collection, xImageLo, xImageHi, yImageLo, yImageHi, xSize, ySize );
+
+ cout << "result image:" << endl << hex;
+ for (int i = 0; i < xSize; i++)
+ {
+ for (int j = 0; j < ySize; j++)
+ {
+ register unsigned char c = *imgPtr;
+ cout << " " << setw(2) << (unsigned short) (c & 0xFF);
+ imgPtr++;
+ }
+ cout << endl;
+ }
+ cout << dec;
+ }
+ catch(r_Error& e)
+ {
+ cout << "Error: cannot access database: " << e.what() << endl << flush;
+ }
+
+
+ // ignore any (previous) errors for connection close
+ try
+ {
+ cout << "aborting transaction..." << flush;
+ transaction.abort();
+
+ cout << "closing database..." << flush;
+ database.close();
+
+ cout << "done." << endl;
+ }
+ catch(r_Error &e)
+ {
+ cout << "Error closing connection: " << e.what() << endl << flush;
+ }
+
+ return 0;
+}
+
+/*
+ * end of query2.cc
+ */