summaryrefslogtreecommitdiffstats
path: root/raslib/test/test_oid.cc
blob: d7c3170dc22f95f56bbc521b7d5b2ac3a29d1672 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
/*
* 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>.
*/
/*************************************************************
 *
 * SOURCE: test_oid.cc
 *
 * MODULE: raslib
 *
 * PURPOSE:
 *
 * COMMENTS:
 *
 ************************************************************/

#include <iostream>
#include <iomanip.h>
// #include <limits.h>
#include "raslib/oid.hh"

#include "raslib/rminit.hh"
RMINITGLOBALS('C')
   
int main()
{   
  cout << endl << endl;
  cout << "OId Examples" << endl;
  cout << "============" << endl << endl;
        
  cout << "Create oid1" << endl;
  r_OId oid1( "testSystem", "testBase", 99 );
  cout << "  oid1........: " << oid1 << endl;
  cout << "   system name: " << oid1.get_system_name() << endl;
  cout << "   base   name: " << oid1.get_base_name()   << endl;
  cout << "   local oid..: " << oid1.get_local_oid()   << endl << endl;

  cout << "Create oid2 with string representation of oid1" << endl;
  r_OId oid2( oid1.get_string_representation() );
  cout << "  oid2........: " << oid2 << endl;
  cout << "   system name: " << oid2.get_system_name() << endl;
  cout << "   base   name: " << oid2.get_base_name()   << endl;
  cout << "   local oid..: " << oid2.get_local_oid()   << endl << endl;

  cout << "Assign oid1 to oid2" << endl;
  oid2 = oid1;
  cout << "  oid2........: " << oid2 << endl;
  cout << "   system name: " << oid2.get_system_name() << endl;
  cout << "   base   name: " << oid2.get_base_name()   << endl;
  cout << "   local oid..: " << oid2.get_local_oid()   << endl << endl;
 
  cout << "Assign temporary oid to oid2" << endl;
  oid2 = r_OId( "testSystem|testBase|100" );
  cout << "  oid2........: " << oid2 << endl;
  cout << "   system name: " << oid2.get_system_name() << endl;
  cout << "   base   name: " << oid2.get_base_name()   << endl;
  cout << "   local oid..: " << oid2.get_local_oid()   << endl << endl;

  cout << "Assign oid1 to oid1" << endl;
  oid1 = oid1;
  cout << "  oid1........: " << oid1 << endl;
  cout << "   system name: " << oid1.get_system_name() << endl;
  cout << "   base   name: " << oid1.get_base_name()   << endl;
  cout << "   local oid..: " << oid1.get_local_oid()   << endl << endl;

  cout << "Create oid3 as a copy of oid1 with the copy constructor" << endl;
  r_OId oid3( oid1 );
  cout << "  oid3........: " << oid3 << endl;
  cout << "   system name: " << oid3.get_system_name() << endl;
  cout << "   base   name: " << oid3.get_base_name()   << endl;
  cout << "   local oid..: " << oid3.get_local_oid()   << endl << endl;

  cout << "Create oid4 with string testSystem|testBase|100" << endl;
  r_OId oid4( "testSystem|testBase|100" );
  cout << "  oid4........: " << oid4 << endl;
  cout << "   system name: " << oid4.get_system_name() << endl;
  cout << "   base   name: " << oid4.get_base_name()   << endl;
  cout << "   local oid..: " << oid4.get_local_oid()   << endl << endl;

  cout << "Create oid5 with string |testBase|100" << endl;
  r_OId oid5( "|testBase|100" );
  cout << "  oid5........: " << oid5 << endl;
  cout << "   system name: " << oid5.get_system_name() << endl;
  cout << "   base   name: " << oid5.get_base_name()   << endl;
  cout << "   local oid..: " << oid5.get_local_oid()   << endl << endl;

  cout << "Create oid6 with string ||100" << endl;
  r_OId oid6( "||100" );
  cout << "  oid6........: " << oid6 << endl;
  cout << "   system name: " << oid6.get_system_name() << endl;
  cout << "   base   name: " << oid6.get_base_name()   << endl;
  cout << "   local oid..: " << oid6.get_local_oid()   << endl << endl;

  cout << "Create oid7 with string |||" << endl;
  r_OId oid7( "|||" );
  cout << "  oid7........: " << oid7 << endl;
  cout << "   system name: " << oid7.get_system_name() << endl;
  cout << "   base   name: " << oid7.get_base_name()   << endl;
  cout << "   local oid..: " << oid7.get_local_oid()   << endl << endl;

  cout << "Create oid8 with an empty string" << endl;
  r_OId oid8( "" );
  cout << "  oid8........: " << oid8 << endl;
  cout << "   system name: " << oid8.get_system_name() << endl;
  cout << "   base   name: " << oid8.get_base_name()   << endl;
  cout << "   local oid..: " << oid8.get_local_oid()   << endl << endl;

  cout << "Create oid9 with just a local oid" << endl;
  r_OId oid9( 0, 0, 100 );
  cout << "  oid8........: " << oid9 << endl;
  cout << "   system name: " << oid9.get_system_name() << endl;
  cout << "   base   name: " << oid9.get_base_name()   << endl;
  cout << "   local oid..: " << oid9.get_local_oid()   << endl << endl;

  cout << "Create oid10 with copy constructor from oid1" << endl;
  r_OId oid10( oid1 );
  cout << "  oid10.......: " << oid10 << endl;
  cout << "   system name: " << oid10.get_system_name() << endl;
  cout << "   base   name: " << oid10.get_base_name()   << endl;
  cout << "   local oid..: " << oid10.get_local_oid()   << endl << endl;

  cout << "Compare r_OId( \"testSystem1|testBase|99\") < r_OId( \"testSystem2|testBase|99\")" << endl;
  cout << (r_OId( "testSystem1|testBase|99") < r_OId( "testSystem2|testBase|99")) << endl << endl;

  cout << "Compare r_OId( \"testSystem|testBase1|99\") < r_OId( \"testSystem|testBase2|99\")" << endl;
  cout << (r_OId( "testSystem|testBase1|99") < r_OId( "testSystem|testBase2|99")) << endl << endl;

  cout << "Compare r_OId( \"testSystem|testBase|99\") < r_OId( \"testSystem|testBase|100\")" << endl;
  cout << (r_OId( "testSystem1|testBase|99") < r_OId( "testSystem2|testBase|100")) << endl << endl;

  cout << "Compare r_OId( \"testSystem1|testBase|99\") > r_OId( \"testSystem2|testBase|99\")" << endl;
  cout << (r_OId( "testSystem1|testBase|99") > r_OId( "testSystem2|testBase|99")) << endl << endl;

  cout << "Compare r_OId( \"testSystem|testBase1|99\") > r_OId( \"testSystem|testBase2|99\")" << endl;
  cout << (r_OId( "testSystem|testBase1|99") > r_OId( "testSystem|testBase2|99")) << endl << endl;

  cout << "Compare r_OId( \"testSystem|testBase|99\") > r_OId( \"testSystem|testBase|100\")" << endl;
  cout << (r_OId( "testSystem1|testBase|99") > r_OId( "testSystem2|testBase|100")) << endl << endl;

  cout << "Create oid11" << endl;
  // cout << "Double limit: " << DBL_MAX << "= 0x" << hex << DBL_MAX << dec << endl;
  double maxDouble = 0xffffffffffff;
  cout << "48bit       : " << setprecision(30) << maxDouble << endl;
  cout << "48bit - 1   : " << setprecision(30) << maxDouble-1 << endl;
  cout << "48bit + 1   : " << setprecision(30) << maxDouble+1 << endl;
  r_OId oid11( "testSystem", "testBase", maxDouble );
  cout << "  oid11.......: " << oid11 << endl;
  cout << "   system name: " << oid11.get_system_name() << endl;
  cout << "   base   name: " << oid11.get_base_name()   << endl;
  cout << "   local oid..: " << oid11.get_local_oid()   << endl << endl;

  cout << endl;

  cout << "Create oid12 with string ''" << endl;
  r_OId oid12( "" );
  cout << "  oid12.......: " << oid12 << endl;
  cout << "   system name: " << oid12.get_system_name() << endl;
  cout << "   base   name: " << oid12.get_base_name()   << endl;
  cout << "   local oid..: " << oid12.get_local_oid()   << endl << endl;

  return 0;
}