1 mike 1.5 //%/////////////////////////////////////////////////////////////////////////////
2 //
|
3 kumpf 1.12 // Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Company, IBM,
4 // The Open Group, Tivoli Systems
|
5 mike 1.5 //
6 // Permission is hereby granted, free of charge, to any person obtaining a copy
|
7 kumpf 1.12 // of this software and associated documentation files (the "Software"), to
8 // deal in the Software without restriction, including without limitation the
9 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
10 mike 1.5 // sell copies of the Software, and to permit persons to whom the Software is
11 // furnished to do so, subject to the following conditions:
12 //
|
13 kumpf 1.12 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
|
14 mike 1.5 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
15 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
16 kumpf 1.12 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
17 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
18 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
19 mike 1.5 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 //
22 //==============================================================================
23 //
24 // Author: Mike Brasher (mbrasher@bmc.com)
25 //
|
26 kumpf 1.8 // Modified By: Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)
|
27 mike 1.5 //
28 //%/////////////////////////////////////////////////////////////////////////////
29
|
30 kumpf 1.11 //#if defined(PEGASUS_EXPLICIT_INSTANTIATION) || !defined(PEGASUS_ARRAY_T)
31 // Only include if not included as general template or if explicit instantiation
32 #if !defined(Pegasus_ArrayInter_h) || defined(PEGASUS_ARRAY_T)
33 #if !defined(PEGASUS_ARRAY_T)
34 #define Pegasus_ArrayInter_h
35 #endif
|
36 mike 1.5
37 /** Array Class.
|
38 mike 1.6 This class is used to represent arrays of intrinsic data types in CIM. And
|
39 mike 1.5 it is also used by the implementation to represent arrays of other kinds of
40 objects (e.g., it is used to implement the String class). However, the user
41 will only use it directly to manipulate arrays of CIM data types.
42 */
43 #ifndef PEGASUS_ARRAY_T
|
44 kumpf 1.11 template<class PEGASUS_ARRAY_T> class Array
|
45 mike 1.5 #else
|
46 kumpf 1.11 PEGASUS_TEMPLATE_SPECIALIZATION class PEGASUS_COMMON_LINKAGE Array<PEGASUS_ARRAY_T>
|
47 mike 1.5 #endif
48 {
49 public:
50
51 /// Default constructor.
52 Array();
53
54 /// Copy Constructor.
55 Array(const Array<PEGASUS_ARRAY_T>& x);
56
57 /** Constructs an array with size elements. The elements are
|
58 kumpf 1.11 initialized with their copy constructor.
59 @param size defines the number of elements
|
60 mike 1.5 */
61 Array(Uint32 size);
62
63 /** Constructs an array with size elements. The elements are
|
64 kumpf 1.11 initialized with x.
|
65 mike 1.5 */
66 Array(Uint32 size, const PEGASUS_ARRAY_T& x);
67
68 /** Constructs an array with size elements. The values come from
|
69 kumpf 1.11 the items pointer.
|
70 mike 1.5 */
71 Array(const PEGASUS_ARRAY_T* items, Uint32 size);
72
73 /// Destructs the objects, freeing any resources.
74 ~Array();
75
76 /// Assignment operator.
77 Array<PEGASUS_ARRAY_T>& operator=(const Array<PEGASUS_ARRAY_T>& x);
78
79 /** Clears the contents of the array. After calling this, size()
|
80 kumpf 1.11 returns zero.
|
81 mike 1.5 */
82 void clear();
83
84 /** Reserves memory for capacity elements. Notice that this does not
|
85 kumpf 1.11 change the size of the array (size() returns what it did before).
86 If the capacity of the array is already greater or equal to the
87 capacity argument, this method has no effect. After calling reserve(),
88 getCapacity() returns a value which is greater or equal to the
89 capacity argument.
90 @param capacity defines the size that is to be reserved
|
91 mike 1.5 */
|
92 kumpf 1.8 void reserve(Uint32 capacity);
|
93 mike 1.5
94 /** Make the size of the array grow by size elements. Thenew size will
|
95 kumpf 1.11 be size() + size. The new elements (there are size of them) are
96 initialized with x.
97 @param size defines the number of elements by which the array is to
98 grow.
|
99 mike 1.5 */
100 void grow(Uint32 size, const PEGASUS_ARRAY_T& x);
101
102 /// Swaps the contents of two arrays.
103 void swap(Array<PEGASUS_ARRAY_T>& x);
104
105 /** Returns the number of elements in the array.
106 @return The number of elements in the array.
107 */
|
108 kumpf 1.8 Uint32 size() const;
|
109 mike 1.5
110 /// Returns the capacity of the array.
|
111 kumpf 1.8 Uint32 getCapacity() const;
|
112 mike 1.5
113 /// Returns a pointer to the first element of the array.
|
114 kumpf 1.8 const PEGASUS_ARRAY_T* getData() const;
|
115 mike 1.5
116 /** Returns the element at the index given by the pos argument.
|
117 kumpf 1.11 @return A reference to the elementdefined by index so that it may be
118 modified.
|
119 mike 1.5 */
120 PEGASUS_ARRAY_T& operator[](Uint32 pos);
121
122 /** Same as the above method except that this is the version called
|
123 kumpf 1.11 on const arrays. The return value cannot be modified since it
124 is constant.
|
125 mike 1.5 */
126 const PEGASUS_ARRAY_T& operator[](Uint32 pos) const;
127
128 /** Appends an element to the end of the array. This increases the size
|
129 kumpf 1.11 of the array by one.
130 @param x Element to append.
|
131 mike 1.5 */
132 void append(const PEGASUS_ARRAY_T& x);
133
134 /// Appends size elements at x to the end of this array.
135 void append(const PEGASUS_ARRAY_T* x, Uint32 size);
136
137 /** Appends one array to another. The size of this array grows by the
|
138 kumpf 1.11 size of the other.
139 @param Array to append.
|
140 mike 1.5 */
|
141 kumpf 1.8 void appendArray(const Array<PEGASUS_ARRAY_T>& x);
|
142 mike 1.5
143 /** Appends one element to the beginning of the array. This increases
|
144 kumpf 1.11 the size by one.
145 @param Element to prepend.
|
146 mike 1.5 */
147 void prepend(const PEGASUS_ARRAY_T& x);
148
149 /** Appends size elements to the array starting at the memory address
|
150 kumpf 1.11 given by x. The array grows by size elements.
|
151 mike 1.5 */
152 void prepend(const PEGASUS_ARRAY_T* x, Uint32 size);
153
154 /** Inserts the element at the given index in the array. Subsequent
|
155 kumpf 1.11 elements are moved down. The size of the array grows by one.
|
156 mike 1.5 */
157 void insert(Uint32 pos, const PEGASUS_ARRAY_T& x);
158
159 /** Inserts size elements at x into the array at the given position.
|
160 kumpf 1.11 Subsequent elements are moved down. The size of the array grows
161 by size elements.
|
162 mike 1.5 */
163 void insert(Uint32 pos, const PEGASUS_ARRAY_T* x, Uint32 size);
164
165 /** Removes the element at the given position from the array. The
|
166 kumpf 1.11 size of the array shrinks by one.
|
167 mike 1.5 */
168 void remove(Uint32 pos);
169
170 /** Removes size elements starting at the given position. The size of
|
171 kumpf 1.11 the array shrinks by size elements.
|
172 mike 1.5 */
173 void remove(Uint32 pos, Uint32 size);
|
174 mike 1.6
175 #ifdef PEGASUS_HAS_EBCDIC
176 void etoa();
177
178 void atoe();
179 #endif
|
180 mike 1.5
181 typedef PEGASUS_ARRAY_T* iterator;
182
183 typedef const PEGASUS_ARRAY_T* const_iterator;
184
|
185 kumpf 1.8 iterator begin();
|
186 mike 1.5
|
187 kumpf 1.8 iterator end();
|
188 mike 1.5
|
189 kumpf 1.8 const_iterator begin() const;
|
190 mike 1.5
|
191 kumpf 1.8 const_iterator end() const;
|
192 mike 1.5
193 private:
194
|
195 kumpf 1.8 PEGASUS_ARRAY_T* _data() const;
|
196 mike 1.5
|
197 kumpf 1.11 void* _rep;
|
198 mike 1.5 };
199
|
200 kumpf 1.11 #endif //!defined(Pegasus_ArrayInter_h) || !defined(PEGASUS_ARRAY_T)
201 //#endif /*defined(PEGASUS_EXPLICIT_INSTANTIATION) || !defined(PEGASUS_ARRAY_T)*/
|