summaryrefslogtreecommitdiffstats
path: root/tags/cpp-1.0-incubating-M2-final/sdo/runtime/core/src/commonj/sdo/DataObjectList.h
blob: 1e9da37141042cc32edaa3de67f587b7717871e2 (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
/*
 * 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 _DATAOBJECTLIST_H_
#define _DATAOBJECTLIST_H_


#include "commonj/sdo/export.h"
#include "commonj/sdo/RefCountingPointer.h"
#include "commonj/sdo/DataObject.h"
#include "commonj/sdo/SDODate.h"
#include <wchar.h>


namespace commonj{
namespace sdo{

/** 
 * 
 * List for retrieving many valued property values, DataType or DataObjectType.
 *
 * DataObjectList provides an API for getting and setting values in
 * many valued properties. The list deals with both DataType and 
 * DataObjectType properties.
 */

class DataObjectList
{
public:
    virtual  ~DataObjectList();

    /**  [] is a index operator, and returns a dataobject.
     *
     * The index operator returns a data object, even if the 
     * list is of a DataType. The data object can yield its true value using
     * getInteger() etc. Alternatively, list elements can be accessed
     * with their correct type using the list getInteger(index) api.
     */

    virtual SDO_API DataObjectPtr operator[] (int pos) = 0;
    virtual SDO_API const DataObjectPtr operator[] (int pos) const = 0;

    /**  size returns the number of elements.
     *
     * The size method returns the number of elements in the list
     */

    virtual SDO_API int size () const = 0;

    /**  getBoolean returns a boolean at an index
     *
     * Each of the DataTypes has a corresponding getter and setter
     * overload. getBoolean returns a bool, getByte returns a char
     * etc
     */

    virtual SDO_API bool getBoolean(unsigned int index) const = 0;
    virtual SDO_API char getByte(unsigned int index) const = 0;
    virtual SDO_API wchar_t getCharacter(unsigned int index) const = 0;
    virtual SDO_API unsigned int getString(unsigned int index, wchar_t* value,
        unsigned int max) const = 0;
    virtual SDO_API unsigned int getBytes(unsigned int index, char* value,
        unsigned int max) const = 0;
    virtual SDO_API short getShort(unsigned int index) const = 0;
    virtual SDO_API long getInteger(unsigned int index) const = 0;
    virtual SDO_API int64_t getLong(unsigned int index) const = 0;
    virtual SDO_API float getFloat(unsigned int index) const = 0;
    virtual SDO_API long double getDouble(unsigned int index) const = 0;
    virtual SDO_API const SDODate  getDate(unsigned int index) const = 0;
    virtual SDO_API const char*  getCString(unsigned int index) const = 0;
    virtual SDO_API DataObjectPtr  getDataObject(unsigned int index) const = 0;

    virtual SDO_API void setBoolean(unsigned int index, bool d)  = 0;
    virtual SDO_API void setByte(unsigned int index, char d)  = 0;
    virtual SDO_API void setCharacter(unsigned int index, wchar_t d)  = 0;
    virtual SDO_API void setString(unsigned int index, const wchar_t* d, unsigned int len)  = 0;
    virtual SDO_API void setBytes(unsigned int index, const char* d, unsigned int len)  = 0;
    virtual SDO_API void setShort(unsigned int index, short d)  = 0;
    virtual SDO_API void setInteger(unsigned int index, long d)  = 0;
    virtual SDO_API void setLong(unsigned int index, int64_t d)  = 0;
    virtual SDO_API void setFloat(unsigned int index, float d)  = 0;
    virtual SDO_API void setDouble(unsigned int index, long double d)  = 0;
    virtual SDO_API void setDate(unsigned int index, const SDODate d)  = 0;
    virtual SDO_API void setCString(unsigned int index, char* d)  = 0;
    virtual SDO_API void setCString(unsigned int index, const SDOString& d)  = 0;
    virtual SDO_API void setDataObject(unsigned int index, DataObjectPtr dob)  = 0;

    /**  getLength returns the length of a string element
     *
     * getLength behaves like DataObject::getlength. It returns the length
     * of a bytes or string buffer such that space can be allocated for the
     * values from getBytes() and getString()
     */

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

    /**  insert and append put items into the list
     *
     * insert and append have overrides for each of the DataTypes, and 
     * for DataObject. Insert inserts before the element number given. If the insertion 
     * point is off the end of the list, then an append is performed.
     * Append puts the element on the end of the list.
     */


    virtual SDO_API void insert (unsigned int index, DataObjectPtr d) = 0;
    virtual SDO_API void append (DataObjectPtr d) = 0;
    
    virtual SDO_API void insert (unsigned int index, bool d) = 0;
    virtual SDO_API void append (bool d) = 0;

    virtual SDO_API void insert (unsigned int index, char d) = 0;
    virtual SDO_API void append (char d) = 0;

    virtual SDO_API void insert (unsigned int index, wchar_t d) = 0;
    virtual SDO_API void append (wchar_t d) = 0;

    virtual SDO_API void insert (unsigned int index, const wchar_t* d, unsigned int len) = 0;
    virtual SDO_API void append (const wchar_t* d, unsigned int len) = 0;

    virtual SDO_API void insert (unsigned int index, const char* d, unsigned int len) = 0;
    virtual SDO_API void append (const char* d, unsigned int len) = 0;

    virtual SDO_API void insert (unsigned int index, const char* d) = 0;
    virtual SDO_API void insert (unsigned int index, const SDOString& d) = 0;
    virtual SDO_API void append (const char* d) = 0;
    virtual SDO_API void append (const SDOString& d) = 0;

    virtual SDO_API void insert (unsigned int index, short d) = 0;
    virtual SDO_API void append (short d) = 0;

    virtual SDO_API void insert (unsigned int index, const SDODate d) = 0;
    virtual SDO_API void append (const SDODate d) = 0;

#if __WORDSIZE !=64
    virtual SDO_API void insert (unsigned int index, long d) = 0;
    virtual SDO_API void append (long d) = 0;
#endif

    virtual SDO_API void insert (unsigned int index, int64_t d) = 0;
    virtual SDO_API void append (int64_t d) = 0;
    
    virtual SDO_API void insert (unsigned int index, float d) = 0;
    virtual SDO_API void append (float d) = 0;


    virtual SDO_API void insert (unsigned int index, long double d) = 0;
    virtual SDO_API void append (long double d) = 0;

    /**  remove removes an element from the list.
     * 
     * Remove removes the element from the list, and passes out a 
     * DataObjectPtr to the old value. This can be attached to the list
     * somewhere else, or discarded.
     */

    virtual SDO_API DataObjectPtr  remove (unsigned int index) = 0;

    /*  getType returns type
     *
     * Returns the type.
     * May throw SDOTYpeNotFoundException for unset open types
     */


   virtual SDO_API const Type& getType() = 0;

    /*  getTypeEnum returns an enumerator for the type
     *
     * Returns an enumerator for the type for easy switching on basic types.
     * The enumerator is part of the Type class
     * May throw SDOTypeNotFoundException for open types
     */

    virtual SDO_API const Type::Types getTypeEnum() = 0;

};
};
};

#endif