1 karl 1.24 //%2005////////////////////////////////////////////////////////////////////////
|
2 mike 1.5 //
|
3 karl 1.23 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
4 // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
5 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
|
6 karl 1.20 // IBM Corp.; EMC Corporation, The Open Group.
|
7 karl 1.23 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
8 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
|
9 karl 1.24 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
|
11 mike 1.5 //
12 // Permission is hereby granted, free of charge, to any person obtaining a copy
|
13 kumpf 1.12 // of this software and associated documentation files (the "Software"), to
14 // deal in the Software without restriction, including without limitation the
15 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
16 mike 1.5 // sell copies of the Software, and to permit persons to whom the Software is
17 // furnished to do so, subject to the following conditions:
18 //
|
19 kumpf 1.12 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
|
20 mike 1.5 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
21 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
22 kumpf 1.12 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
23 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
24 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
25 mike 1.5 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 //
28 //==============================================================================
29 //
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 /** This class is used to represent arrays of intrinsic data types in CIM.
|
42 mike 1.5 */
|
43 kumpf 1.11 template<class PEGASUS_ARRAY_T> class Array
|
44 mike 1.5 #else
|
45 kumpf 1.11 PEGASUS_TEMPLATE_SPECIALIZATION class PEGASUS_COMMON_LINKAGE Array<PEGASUS_ARRAY_T>
|
46 mike 1.5 #endif
47 {
48 public:
49
|
50 karl 1.21 /** Constructs an array object with null values (default constructor).
51 */
|
52 mike 1.5 Array();
53
|
54 karl 1.21 /** Creates a new Array object using the parameters and values in the Array object.
55 @param x Specifies the new Array object name.
56 */
|
57 mike 1.5 Array(const Array<PEGASUS_ARRAY_T>& x);
58
59 /** Constructs an array with size elements. The elements are
|
60 kumpf 1.11 initialized with their copy constructor.
|
61 karl 1.21 @param size Defines the number of elements.
|
62 mike 1.5 */
63 Array(Uint32 size);
64
65 /** Constructs an array with size elements. The elements are
|
66 karl 1.21 initialized with array x.
67 @param size Defines the number of elements.
68 @param x Specifies the new array object name.
|
69 mike 1.5 */
70 Array(Uint32 size, const PEGASUS_ARRAY_T& x);
71
72 /** Constructs an array with size elements. The values come from
|
73 kumpf 1.11 the items pointer.
|
74 karl 1.21 @param items References the values of the specified array.
75 @param size Uint32 representing how many elements are in the array.
|
76 mike 1.5 */
77 Array(const PEGASUS_ARRAY_T* items, Uint32 size);
78
|
79 karl 1.21 /**Destroys the objects, freeing any resources.
80 */
|
81 mike 1.5 ~Array();
82
|
83 karl 1.21 /**The values of one array object are assigned to another (assignment operator).
84 @param x Array object to assign the Array parameters to.
85 */
|
86 mike 1.5 Array<PEGASUS_ARRAY_T>& operator=(const Array<PEGASUS_ARRAY_T>& x);
87
88 /** Clears the contents of the array. After calling this, size()
|
89 kumpf 1.11 returns zero.
|
90 mike 1.5 */
91 void clear();
92
93 /** Reserves memory for capacity elements. Notice that this does not
|
94 kumpf 1.11 change the size of the array (size() returns what it did before).
95 If the capacity of the array is already greater or equal to the
|
96 kumpf 1.14 capacity argument, this method has no effect. After calling
97 reserveCapacity(), getCapacity() returns a value which is greater
98 or equal to the capacity argument.
|
99 karl 1.21 @param capacity Defines the size that is to be reserved
|
100 mike 1.5 */
|
101 kumpf 1.14 void reserveCapacity(Uint32 capacity);
|
102 mike 1.5
|
103 kumpf 1.19 /** Make the size of the array grow by size elements. The new size will
|
104 kumpf 1.11 be size() + size. The new elements (there are size of them) are
105 initialized with x.
|
106 karl 1.21 @param size Defines the number of elements by which the array is to
|
107 kumpf 1.11 grow.
|
108 mike 1.5 */
109 void grow(Uint32 size, const PEGASUS_ARRAY_T& x);
110
|
111 karl 1.21 /** Swaps the contents of two arrays. Array x references the original values in the Array object (y) and the values of the Array object (y) reference the original values of Array x.
112 */
|
113 mike 1.5 void swap(Array<PEGASUS_ARRAY_T>& x);
114
115 /** Returns the number of elements in the array.
|
116 karl 1.21 @return The number of elements in the array.
|
117 mike 1.5 */
|
118 kumpf 1.8 Uint32 size() const;
|
119 mike 1.5
|
120 karl 1.21 /** Returns the capacity of the array.
121 @return The capacity of the array.
122 */
|
123 kumpf 1.8 Uint32 getCapacity() const;
|
124 mike 1.5
|
125 karl 1.21 /** Returns a pointer to the first element of the array.
126 @return A pointer to the first element of the array.
127 */
|
128 kumpf 1.8 const PEGASUS_ARRAY_T* getData() const;
|
129 mike 1.5
|
130 kumpf 1.18 /** Returns the element indicated by the index argument.
131 @return A reference to the element defined by index so that it may be
|
132 kumpf 1.11 modified.
|
133 mike 1.5 */
|
134 kumpf 1.18 PEGASUS_ARRAY_T& operator[](Uint32 index);
|
135 mike 1.5
|
136 karl 1.21 /** Returns the element in the const array specified as the index argument. The return value cannot be modified since it
|
137 kumpf 1.11 is constant.
|
138 karl 1.21 @return A reference to the element defined by index but the reference cannot be modified.
|
139 mike 1.5 */
|
140 kumpf 1.18 const PEGASUS_ARRAY_T& operator[](Uint32 index) const;
|
141 mike 1.5
142 /** Appends an element to the end of the array. This increases the size
|
143 kumpf 1.11 of the array by one.
144 @param x Element to append.
|
145 mike 1.5 */
146 void append(const PEGASUS_ARRAY_T& x);
147
|
148 karl 1.21 /** Appends size elements at x to the end of this array.
149 @param size Uint32 value to append to the size of the array.
150 */
|
151 mike 1.5 void append(const PEGASUS_ARRAY_T* x, Uint32 size);
152
153 /** Appends one array to another. The size of this array grows by the
|
154 kumpf 1.11 size of the other.
|
155 karl 1.21 @param x Array to add to the appended array.
|
156 mike 1.5 */
|
157 kumpf 1.8 void appendArray(const Array<PEGASUS_ARRAY_T>& x);
|
158 mike 1.5
159 /** Appends one element to the beginning of the array. This increases
|
160 kumpf 1.11 the size by one.
|
161 karl 1.21 @param x The element to pre pend.
|
162 mike 1.5 */
163 void prepend(const PEGASUS_ARRAY_T& x);
164
165 /** Appends size elements to the array starting at the memory address
|
166 kumpf 1.11 given by x. The array grows by size elements.
|
167 karl 1.21 @param size Uint32 size to add to the array at address x.
168 @param x Specifies where to begin increasing size elements of the array.
|
169 mike 1.5 */
170 void prepend(const PEGASUS_ARRAY_T* x, Uint32 size);
171
172 /** Inserts the element at the given index in the array. Subsequent
|
173 kumpf 1.11 elements are moved down. The size of the array grows by one.
|
174 karl 1.21 @param x Specifies the element to add to the array.
|
175 mike 1.5 */
|
176 kumpf 1.18 void insert(Uint32 index, const PEGASUS_ARRAY_T& x);
|
177 mike 1.5
|
178 kumpf 1.18 /** Inserts size elements at x into the array at the given index.
|
179 kumpf 1.11 Subsequent elements are moved down. The size of the array grows
180 by size elements.
|
181 karl 1.21 @param x Specifies where to begin adding elements in the array.
182 @param size Uint32 size to add to the array starting at element x.
|
183 mike 1.5 */
|
184 kumpf 1.18 void insert(Uint32 index, const PEGASUS_ARRAY_T* x, Uint32 size);
|
185 mike 1.5
|
186 kumpf 1.18 /** Removes the element at the given index from the array. The
|
187 kumpf 1.11 size of the array shrinks by one.
|
188 karl 1.21 @param index Specifies the array element to remove.
|
189 mike 1.5 */
|
190 kumpf 1.18 void remove(Uint32 index);
|
191 mike 1.5
|
192 kumpf 1.18 /** Removes size elements starting at the given index. The size of
|
193 kumpf 1.11 the array shrinks by size elements.
|
194 karl 1.21 @param index Specifies where in the array to begin removing elements.
195 @param size Uint32 size that specifies how many elements to remove from the array.
|
196 mike 1.5 */
|
197 kumpf 1.18 void remove(Uint32 index, Uint32 size);
|
198 mike 1.6
|
199 mike 1.5 private:
200
|
201 kumpf 1.8 PEGASUS_ARRAY_T* _data() const;
|
202 mike 1.5
|
203 kumpf 1.11 void* _rep;
|
204 mike 1.5 };
205
|
206 kumpf 1.11 #endif //!defined(Pegasus_ArrayInter_h) || !defined(PEGASUS_ARRAY_T)
|