1 martin 1.28 //%LICENSE////////////////////////////////////////////////////////////////
|
2 martin 1.29 //
|
3 martin 1.28 // Licensed to The Open Group (TOG) under one or more contributor license
4 // agreements. Refer to the OpenPegasusNOTICE.txt file distributed with
5 // this work for additional information regarding copyright ownership.
6 // Each contributor licenses this file to you under the OpenPegasus Open
7 // Source License; you may not use this file except in compliance with the
8 // License.
|
9 martin 1.29 //
|
10 martin 1.28 // Permission is hereby granted, free of charge, to any person obtaining a
11 // copy of this software and associated documentation files (the "Software"),
12 // to deal in the Software without restriction, including without limitation
13 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 // and/or sell copies of the Software, and to permit persons to whom the
15 // Software is furnished to do so, subject to the following conditions:
|
16 martin 1.29 //
|
17 martin 1.28 // The above copyright notice and this permission notice shall be included
18 // in all copies or substantial portions of the Software.
|
19 martin 1.29 //
|
20 martin 1.28 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
21 martin 1.29 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
22 martin 1.28 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23 // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
24 // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
25 // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
26 // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
27 martin 1.29 //
|
28 martin 1.28 //////////////////////////////////////////////////////////////////////////
|
29 mike 1.5 //
30 //%/////////////////////////////////////////////////////////////////////////////
31
|
32 kumpf 1.11 // Only include if not included as general template or if explicit instantiation
33 #if !defined(Pegasus_ArrayInter_h) || defined(PEGASUS_ARRAY_T)
34 #if !defined(PEGASUS_ARRAY_T)
35 #define Pegasus_ArrayInter_h
36 #endif
|
37 mike 1.5
|
38 kumpf 1.16 #include <Pegasus/Common/Linkage.h>
39
|
40 kumpf 1.19 #ifndef PEGASUS_ARRAY_T
|
41 kumpf 1.26 /**
42 This class is used to represent arrays of intrinsic data types in CIM.
|
43 mike 1.5 */
|
44 kumpf 1.11 template<class PEGASUS_ARRAY_T> class Array
|
45 mike 1.5 #else
|
46 kumpf 1.26 PEGASUS_TEMPLATE_SPECIALIZATION
47 class PEGASUS_COMMON_LINKAGE Array<PEGASUS_ARRAY_T>
|
48 mike 1.5 #endif
49 {
50 public:
51
|
52 kumpf 1.26 /**
53 Constructs an array object with null values (default constructor).
54 */
|
55 mike 1.5 Array();
56
|
57 kumpf 1.26 /**
58 Creates a new Array object using the parameters and values in the
59 Array object.
60 @param x Specifies the new Array object name.
61 */
|
62 mike 1.5 Array(const Array<PEGASUS_ARRAY_T>& x);
63
|
64 kumpf 1.26 /**
65 Constructs an array with size elements. The elements are
|
66 kumpf 1.11 initialized with their copy constructor.
|
67 karl 1.21 @param size Defines the number of elements.
|
68 mike 1.5 */
69 Array(Uint32 size);
70
|
71 kumpf 1.26 /**
72 Constructs an array with size elements. The elements are
|
73 karl 1.21 initialized with array x.
|
74 kumpf 1.26 @param size Defines the number of elements.
75 @param x Specifies the new array object name.
|
76 mike 1.5 */
77 Array(Uint32 size, const PEGASUS_ARRAY_T& x);
78
|
79 kumpf 1.26 /**
80 Constructs an array with size elements. The values come from
|
81 kumpf 1.11 the items pointer.
|
82 kumpf 1.26 @param items References the values of the specified array.
83 @param size Uint32 representing how many elements are in the array.
|
84 mike 1.5 */
85 Array(const PEGASUS_ARRAY_T* items, Uint32 size);
86
|
87 kumpf 1.26 /**
88 Destroys the objects, freeing any resources.
|
89 karl 1.21 */
|
90 mike 1.5 ~Array();
91
|
92 kumpf 1.26 /**
93 The values of one array object are assigned to another (assignment
94 operator).
95 @param x Array object to assign the Array parameters to.
|
96 karl 1.21 */
|
97 mike 1.5 Array<PEGASUS_ARRAY_T>& operator=(const Array<PEGASUS_ARRAY_T>& x);
98
|
99 kumpf 1.26 /**
100 Clears the contents of the array. After calling this, size()
|
101 kumpf 1.11 returns zero.
|
102 mike 1.5 */
103 void clear();
104
|
105 kumpf 1.26 /**
106 Reserves memory for capacity elements. Notice that this does not
|
107 kumpf 1.11 change the size of the array (size() returns what it did before).
108 If the capacity of the array is already greater or equal to the
|
109 kumpf 1.14 capacity argument, this method has no effect. After calling
110 reserveCapacity(), getCapacity() returns a value which is greater
111 or equal to the capacity argument.
|
112 karl 1.21 @param capacity Defines the size that is to be reserved
|
113 mike 1.5 */
|
114 kumpf 1.14 void reserveCapacity(Uint32 capacity);
|
115 mike 1.5
|
116 kumpf 1.26 /**
117 Make the size of the array grow by size elements. The new size will
|
118 kumpf 1.11 be size() + size. The new elements (there are size of them) are
119 initialized with x.
|
120 karl 1.21 @param size Defines the number of elements by which the array is to
|
121 kumpf 1.11 grow.
|
122 kumpf 1.27 @param x The element value with which to initialize the new elements.
|
123 mike 1.5 */
124 void grow(Uint32 size, const PEGASUS_ARRAY_T& x);
125
|
126 kumpf 1.26 /**
127 Swaps the contents of two arrays. After the swap, Array x references
128 the original values of this Array object and this Array object
129 references the original values of Array x.
130 @param x The Array with which to swap values.
|
131 karl 1.21 */
|
132 mike 1.5 void swap(Array<PEGASUS_ARRAY_T>& x);
133
|
134 kumpf 1.26 /**
135 Returns the number of elements in the array.
|
136 karl 1.21 @return The number of elements in the array.
|
137 mike 1.5 */
|
138 kumpf 1.8 Uint32 size() const;
|
139 mike 1.5
|
140 kumpf 1.26 /**
141 Returns the capacity of the array.
142 @return The capacity of the array.
|
143 karl 1.21 */
|
144 kumpf 1.8 Uint32 getCapacity() const;
|
145 mike 1.5
|
146 kumpf 1.26 /**
147 Returns a pointer to the first element of the array.
148 @return A pointer to the first element of the array.
149 */
|
150 kumpf 1.8 const PEGASUS_ARRAY_T* getData() const;
|
151 mike 1.5
|
152 kumpf 1.26 /**
153 Returns the element indicated by the index argument.
|
154 kumpf 1.18 @return A reference to the element defined by index so that it may be
|
155 kumpf 1.11 modified.
|
156 mike 1.5 */
|
157 kumpf 1.18 PEGASUS_ARRAY_T& operator[](Uint32 index);
|
158 mike 1.5
|
159 kumpf 1.26 /**
160 Returns the element in the const array specified as the index argument.
161 The return value cannot be modified since it is constant.
162 @return A reference to the element defined by index but the reference
163 cannot be modified.
|
164 mike 1.5 */
|
165 kumpf 1.18 const PEGASUS_ARRAY_T& operator[](Uint32 index) const;
|
166 mike 1.5
|
167 kumpf 1.26 /**
168 Appends an element to the end of the array. This increases the size
|
169 kumpf 1.11 of the array by one.
170 @param x Element to append.
|
171 mike 1.5 */
172 void append(const PEGASUS_ARRAY_T& x);
173
|
174 kumpf 1.26 /**
175 Appends size elements at x to the end of this array.
|
176 kumpf 1.27 @param x Pointer to a buffer containing the elements to append.
177 @param size A Uint32 value specifying the number of elements to append.
|
178 kumpf 1.26 */
|
179 mike 1.5 void append(const PEGASUS_ARRAY_T* x, Uint32 size);
180
|
181 kumpf 1.26 /**
182 Appends one array to another. The size of this array grows by the
|
183 kumpf 1.11 size of the other.
|
184 kumpf 1.26 @param x Array to add to the appended array.
|
185 mike 1.5 */
|
186 kumpf 1.8 void appendArray(const Array<PEGASUS_ARRAY_T>& x);
|
187 mike 1.5
|
188 kumpf 1.26 /**
189 Appends one element to the beginning of the array. This increases
|
190 kumpf 1.11 the size by one.
|
191 kumpf 1.27 @param x The element to prepend.
|
192 mike 1.5 */
193 void prepend(const PEGASUS_ARRAY_T& x);
194
|
195 kumpf 1.26 /**
|
196 kumpf 1.27 Prepends a specified number of elements from a buffer to the array.
197 @param x Pointer to a buffer containing the elements to prepend.
198 @param size A Uint32 value specifying the number of elements to prepend.
|
199 mike 1.5 */
200 void prepend(const PEGASUS_ARRAY_T* x, Uint32 size);
201
|
202 kumpf 1.26 /**
203 Inserts the element at the given index in the array. Subsequent
|
204 kumpf 1.11 elements are moved down. The size of the array grows by one.
|
205 kumpf 1.27 @param index The index at which to insert the element into the array.
|
206 kumpf 1.26 @param x Specifies the element to add to the array.
|
207 mike 1.5 */
|
208 kumpf 1.18 void insert(Uint32 index, const PEGASUS_ARRAY_T& x);
|
209 mike 1.5
|
210 kumpf 1.26 /**
|
211 kumpf 1.27 Inserts a specified number of elements from a buffer into the array at
212 a given index. Subsequent elements are moved down. The size of the
213 array grows by the specified number of elements.
214 @param index The index at which to insert the elements into the array.
215 @param x Pointer to a buffer containing the elements to insert.
216 @param size A Uint32 value specifying the number of elements to insert.
|
217 mike 1.5 */
|
218 kumpf 1.18 void insert(Uint32 index, const PEGASUS_ARRAY_T* x, Uint32 size);
|
219 mike 1.5
|
220 kumpf 1.26 /**
221 Removes the element at the given index from the array. The
|
222 kumpf 1.11 size of the array shrinks by one.
|
223 kumpf 1.26 @param index Specifies the array element to remove.
|
224 mike 1.5 */
|
225 kumpf 1.18 void remove(Uint32 index);
|
226 mike 1.5
|
227 kumpf 1.26 /**
228 Removes size elements starting at the given index. The size of
|
229 kumpf 1.11 the array shrinks by size elements.
|
230 kumpf 1.26 @param index Specifies where in the array to begin removing elements.
231 @param size Uint32 size that specifies how many elements to remove
232 from the array.
|
233 mike 1.5 */
|
234 kumpf 1.18 void remove(Uint32 index, Uint32 size);
|
235 mike 1.6
|
236 mike 1.5 private:
237
|
238 kumpf 1.8 PEGASUS_ARRAY_T* _data() const;
|
239 mike 1.5
|
240 kumpf 1.11 void* _rep;
|
241 mike 1.5 };
242
|
243 kumpf 1.11 #endif //!defined(Pegasus_ArrayInter_h) || !defined(PEGASUS_ARRAY_T)
|