summaryrefslogtreecommitdiffstats
path: root/tags/cpp-sdo-1.0.incubating-M3/runtime/core/src/commonj/sdo/Sequence.h
blob: 9a810c22843ce058c0b449969e1f839b416f0ab6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 *   
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

/* $Rev$ $Date$ */

#ifndef _SEQUENCE_H_
#define _SEQUENCE_H_


#include "commonj/sdo/export.h"
#include "commonj/sdo/RefCountingObject.h"
#include "commonj/sdo/RefCountingPointer.h"
#include "commonj/sdo/SDODate.h"
#include "commonj/sdo/Type.h"
#include "commonj/sdo/SDOValue.h"


namespace commonj{
namespace sdo{

class Property; /* forward declaration */
class DataObject;

/**  
 * A sequence is a heterogeneous list of properties and corresponding values.
 * It represents an ordered arbitrary mixture of data values from more 
 * than one property of a {@link DataObject data object}.
 */

class Sequence : public RefCountingObject
{
    public:
    /**  size() returns the number of elements 
     *
     * Returns the number of entries in the sequence.
     */

    SDO_API virtual unsigned int size() = 0;

    /**
     *
     * A Sequence element is either a free text item, or represents a property
     * setting. If the element is a property setting, then the information 
     * held in the element consists of:
     * -# The property which was set.
     * -# The element of that property if it was many valued.
     * -# The value which was set.
     *
     * If the sequence element is text, then there is no property, and only the
     * methods for text retrieval will work. Use the isText() method to check
     * before calling getProperty().
     */

    SDO_API virtual const Property& getProperty(unsigned int index) = 0;

    /**
     * Return the data object associated with this sequence
     */

    SDO_API virtual const DataObjectPtr getDataObject() = 0;

    /**
     *
     * The element of that property if it was many valued. Zero if the 
     * property was single valued.
     */

    SDO_API virtual unsigned int getListIndex(unsigned int index) = 0;

    /**
     *
     * The element contains the actual value set within the property. The
     * method required to get that value will vary depending on the type
     * of the property. This is shorthand for getProperty.getTypeEnum().
     */

    SDO_API virtual Type::Types getTypeEnum(unsigned int index) = 0;

    /**
     *
     * This method searched the sequence for a setting which corresponds
     * to the specified index of the specified property. Searches for single
     * valued property settings may omit the pindex parameter.
     */


    SDO_API virtual unsigned int getIndex(const Property& p, unsigned int pindex=0) = 0;
    SDO_API virtual unsigned int getIndex(const char* propName, unsigned int pindex=0) = 0;

    /**
     *
     * These methods retrieve the setting according to the type of the
     * property concerned. If a retrieval method is used which does not correspond to
     * the correct type, a conversion will be performed, or an illegal conversion
     * exception will be thrown.
     */

    SDO_API virtual const char* getCStringValue(unsigned int index) = 0;
    SDO_API virtual bool        getBooleanValue(unsigned int index) = 0;
    SDO_API virtual char        getByteValue(unsigned int index) = 0;
    SDO_API virtual wchar_t     getCharacterValue(unsigned int index) = 0;
    SDO_API virtual unsigned int getStringValue(unsigned int index, wchar_t* val, unsigned int max) = 0;
    SDO_API virtual unsigned int getBytesValue(unsigned int index, char* val, unsigned int max) = 0;
    SDO_API virtual short       getShortValue(unsigned int index) = 0;
    SDO_API virtual long         getIntegerValue(unsigned int index) = 0;    
    SDO_API virtual int64_t     getLongValue(unsigned int index) = 0;
    SDO_API virtual float       getFloatValue(unsigned int index) = 0;
    SDO_API virtual long double getDoubleValue(unsigned int index) = 0;
    SDO_API virtual const SDODate      getDateValue(unsigned int index) = 0;
    SDO_API virtual DataObjectPtr getDataObjectValue(unsigned int index) = 0;
    SDO_API virtual const SDOValue&    getSDOValue(unsigned int index) = 0;

    /**
     *
     * getlength applies to string and byte buffer types, and allows the
     * client to allocate the correct size of buffer before retrieving the 
     * value.
     */

    SDO_API virtual unsigned int getLength(unsigned int index) = 0;


    /**
     *
     * The setter methods use an element of the sequence to perform a 
     * property setting. The value in the sequence is updated, and so is the
     * rel value of the property in the data object.
     */

    SDO_API virtual void setCStringValue(   unsigned int index, const char* s ) = 0;
    SDO_API virtual void setBooleanValue(   unsigned int index, bool        b ) = 0;
    SDO_API virtual void setByteValue(      unsigned int index, char        c ) = 0;
    SDO_API virtual void setCharacterValue( unsigned int index, wchar_t     c ) = 0;
    SDO_API virtual void setStringValue(    unsigned int index, const wchar_t* s , unsigned int len) = 0;
    SDO_API virtual void setBytesValue(     unsigned int index, const char* s , unsigned int len) = 0;
    SDO_API virtual void setShortValue(     unsigned int index, short       s ) = 0;
    SDO_API virtual void setIntegerValue(       unsigned int index, long         i ) = 0;    
    SDO_API virtual void setLongValue(  unsigned int index, int64_t     l ) = 0;
    SDO_API virtual void setFloatValue(     unsigned int index, float       f ) = 0;
    SDO_API virtual void setDoubleValue(unsigned int index, long double d ) = 0;
    SDO_API virtual void setDateValue(unsigned int index, const SDODate t ) = 0;
    SDO_API virtual void setDataObjectValue(unsigned int index, DataObjectPtr d ) = 0;


    /**
     *
     * Sequences may be added to by usign the addXXX methods. These provoke
     * a setting of the real value of the property concerned, and also append
     * an element to the sequence to reflect that setting.
     * Additions may be performed based on property name, property index or
     * the Property itself.
     */
    
    SDO_API virtual bool addCString(   const char* propertyName,const char* s ) = 0;
    SDO_API virtual bool addBoolean(   const char* propertyName,bool        b ) = 0;
    SDO_API virtual bool addByte(      const char* propertyName,char        c ) = 0;
    SDO_API virtual bool addCharacter( const char* propertyName,wchar_t     c ) = 0;
    SDO_API virtual bool addString(    const char* propertyName,const wchar_t* s , unsigned int len) = 0;
    SDO_API virtual bool addBytes (    const char* propertyName,const char* s , unsigned int len) = 0;
    SDO_API virtual bool addShort(     const char* propertyName,short       s ) = 0;
    SDO_API virtual bool addInteger(       const char* propertyName,long         i ) = 0;    
    SDO_API virtual bool addLong(  const char* propertyName,int64_t     l ) = 0;
    SDO_API virtual bool addFloat(     const char* propertyName,float       f ) = 0;
    SDO_API virtual bool addDouble(const char* propertyName,long double d ) = 0;
    SDO_API virtual bool addDate(const char* propertyName,const SDODate t ) = 0;
    SDO_API virtual bool addDataObject(const char* propertyName,DataObjectPtr d ) = 0;
    SDO_API virtual bool addSDOValue(const char* propertyName, const SDOValue& sval) = 0;

 
    SDO_API virtual bool addCString(   unsigned int propertyIndex,const char* s ) = 0;
    SDO_API virtual bool addBoolean(   unsigned int propertyIndex,bool        b ) = 0;
    SDO_API virtual bool addByte(      unsigned int propertyIndex,char        c ) = 0;
    SDO_API virtual bool addCharacter( unsigned int propertyIndex,wchar_t     c ) = 0;
    SDO_API virtual bool addString(    unsigned int propertyIndex,const wchar_t* s , unsigned int len) = 0;
    SDO_API virtual bool addBytes(     unsigned int propertyIndex,const char* s , unsigned int len) = 0;
    SDO_API virtual bool addShort(     unsigned int propertyIndex,short       s ) = 0;
    SDO_API virtual bool addInteger(       unsigned int propertyIndex,long         i ) = 0;    
    SDO_API virtual bool addLong(  unsigned int propertyIndex,int64_t     l ) = 0;
    SDO_API virtual bool addFloat(     unsigned int propertyIndex,float       f ) = 0;
    SDO_API virtual bool addDouble(unsigned int propertyIndex,long double d ) = 0;
    SDO_API virtual bool addDate(unsigned int propertyIndex,const SDODate t ) = 0;
    SDO_API virtual bool addDataObject(unsigned int propertyIndex,DataObjectPtr d ) = 0;
    SDO_API virtual bool addSDOValue(unsigned int propertyIndex, const SDOValue& sval) = 0;



    SDO_API virtual bool addCString(   const Property& property,const char* s ) = 0;
    SDO_API virtual bool addBoolean(   const Property& property,bool        b ) = 0;
    SDO_API virtual bool addByte(      const Property& property,char        c ) = 0;
    SDO_API virtual bool addCharacter( const Property& property,wchar_t     c ) = 0;
    SDO_API virtual bool addString   ( const Property& property,const wchar_t* s , unsigned int len) = 0;
    SDO_API virtual bool addBytes(     const Property& property,const char* s , unsigned int len) = 0;
    SDO_API virtual bool addShort(     const Property& property,short       s ) = 0;
    SDO_API virtual bool addInteger(       const Property& property,long         i ) = 0;    
    SDO_API virtual bool addLong(  const Property& property,int64_t     l ) = 0;
    SDO_API virtual bool addFloat(     const Property& property,float       f ) = 0;
    SDO_API virtual bool addDouble(const Property& property,long double d ) = 0;
    SDO_API virtual bool addDate(const Property& property,const SDODate t ) = 0;
    SDO_API virtual bool addDataObject(const Property& property,DataObjectPtr d ) = 0;
    SDO_API virtual bool addSDOValue(const Property& property, const SDOValue& sval) = 0;


    /**
     *
     * Sequences may be added to by usign the addXXX methods. These provoke
     * a setting of the real value of the property concerned, and also append
     * an element to the sequence to reflect that setting.
     * Additions may be performed based on property name, property index or
     * the Property itself. 
     * The add method also has an override to allow insertion of a sequence element
     * before any index.
     */

    SDO_API virtual bool addCString(   unsigned int index,const char* propertyName,const char* s ) = 0;
    SDO_API virtual bool addBoolean(   unsigned int index,const char* propertyName,bool        b ) = 0;
    SDO_API virtual bool addByte(      unsigned int index,const char* propertyName,char        c ) = 0;
    SDO_API virtual bool addCharacter( unsigned int index,const char* propertyName,wchar_t     c ) = 0;
    SDO_API virtual bool addString(    unsigned int index,const char* propertyName,const wchar_t* s, unsigned int len ) = 0;
    SDO_API virtual bool addBytes(     unsigned int index,const char* propertyName,const char* s , unsigned int len) = 0;
    SDO_API virtual bool addShort(     unsigned int index,const char* propertyName,short       s ) = 0;
    SDO_API virtual bool addInteger(       unsigned int index,const char* propertyName,long         i ) = 0;    
    SDO_API virtual bool addLong(  unsigned int index,const char* propertyName,int64_t     l ) = 0;
    SDO_API virtual bool addFloat(     unsigned int index,const char* propertyName,float       f ) = 0;
    SDO_API virtual bool addDouble(unsigned int index,const char* propertyName,long double d ) = 0;
    SDO_API virtual bool addDate(unsigned int index,const char* propertyName,const SDODate t ) = 0;
    SDO_API virtual bool addDataObject(unsigned int index,const char* propertyName,DataObjectPtr d ) = 0;
    SDO_API virtual bool addSDOValue(unsigned int index, const char* propertyName, const SDOValue& sval) = 0;


    SDO_API virtual bool addCString(   unsigned int index,unsigned int propertyIndex,const char* s ) = 0;
    SDO_API virtual bool addBoolean(   unsigned int index,unsigned int propertyIndex,bool        b ) = 0;
    SDO_API virtual bool addByte(      unsigned int index,unsigned int propertyIndex,char        c ) = 0;
    SDO_API virtual bool addCharacter( unsigned int index,unsigned int propertyIndex,wchar_t     c ) = 0;
    SDO_API virtual bool addString(    unsigned int index,unsigned int propertyIndex,const wchar_t* s , unsigned int len) = 0;
    SDO_API virtual bool addBytes(     unsigned int index,unsigned int propertyIndex,const char* s , unsigned int len) = 0;
    SDO_API virtual bool addShort(     unsigned int index,unsigned int propertyIndex,short       s ) = 0;
    SDO_API virtual bool addInteger(       unsigned int index,unsigned int propertyIndex,long         i ) = 0;    
    SDO_API virtual bool addLong(  unsigned int index,unsigned int propertyIndex,int64_t     l ) = 0;
    SDO_API virtual bool addFloat(     unsigned int index,unsigned int propertyIndex,float       f ) = 0;
    SDO_API virtual bool addDouble(unsigned int index,unsigned int propertyIndex,long double d ) = 0;
    SDO_API virtual bool addDate(unsigned int index,unsigned int propertyIndex,const SDODate t ) = 0;
    SDO_API virtual bool addDataObject(unsigned int index,unsigned int propertyIndex,DataObjectPtr d ) = 0;
    SDO_API virtual bool addSDOValue(unsigned int index, unsigned int propertyIndex, const SDOValue& sval) = 0;


    SDO_API virtual bool addCString(   unsigned int index,const Property& property,const char* s ) = 0;
    SDO_API virtual bool addBoolean(   unsigned int index,const Property& property,bool        b ) = 0;
    SDO_API virtual bool addByte(      unsigned int index,const Property& property,char        c ) = 0;
    SDO_API virtual bool addCharacter( unsigned int index,const Property& property,wchar_t     c ) = 0;
    SDO_API virtual bool addString(    unsigned int index,const Property& property,const wchar_t* s , unsigned int len) = 0;
    SDO_API virtual bool addBytes(     unsigned int index,const Property& property,const char* s , unsigned int len) = 0;
    SDO_API virtual bool addShort(     unsigned int index,const Property& property,short       s ) = 0;
    SDO_API virtual bool addInteger(       unsigned int index,const Property& property,long         i ) = 0;    
    SDO_API virtual bool addLong(  unsigned int index,const Property& property,int64_t     l ) = 0;
    SDO_API virtual bool addFloat(     unsigned int index,const Property& property,float       f ) = 0;
    SDO_API virtual bool addDouble(unsigned int index,const Property& property,long double d ) = 0;
    SDO_API virtual bool addDate(unsigned int index,const Property& property,const SDODate t ) = 0;
    SDO_API virtual bool addDataObject(unsigned int index,const Property& property,DataObjectPtr d ) = 0;
    SDO_API virtual bool addSDOValue(unsigned int index, const Property& property, const SDOValue& sval) = 0;

 
    /**  remove() removes an item.
     *
     * Remove the item at the specified index in the sequence. 
     * This has no effect on the value of the property in the data object,
     * but the setting is no longer recorded.
     */
    SDO_API virtual void remove(unsigned int index) = 0;
    SDO_API virtual void removeAll(const Property& p) = 0;

    /**
     * Moves an entry in the sequence from one index to another. This 
     * makes the entry appear to have been set at a different point in
     * the sequence, but does not alter the actual value set.
     */

    SDO_API virtual void move(unsigned int toIndex, unsigned int fromIndex) = 0;

    /**
     * The text setting APIs add an element to the sequence which 
     * is not a property setting. 
     * This is text which may be retieved in sequence with the settings.
     */

    SDO_API virtual bool addText(const char* text) = 0;
    SDO_API virtual bool addText(unsigned int index, const char* text) = 0;
    SDO_API virtual bool setText(unsigned int index, const char* text) = 0;

    /**
     * isText returns true if the element is not a property setting.
     * This method should be used before getting the Property, to avoid an
     * exception
     */
    
    SDO_API virtual bool isText(unsigned int index) = 0;

};


};
};

#endif //_SEQUENCE_H_