1 karl 1.20 //%2003////////////////////////////////////////////////////////////////////////
|
2 mike 1.5 //
|
3 karl 1.20 // 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 // IBM Corp.; EMC Corporation, The Open Group.
|
7 mike 1.5 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
|
9 kumpf 1.12 // of this software and associated documentation files (the "Software"), to
10 // deal in the Software without restriction, including without limitation the
11 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
12 mike 1.5 // sell copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
14 //
|
15 kumpf 1.12 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
|
16 mike 1.5 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
17 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
18 kumpf 1.12 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
19 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
21 mike 1.5 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 //
24 //==============================================================================
25 //
26 // Author: Mike Brasher (mbrasher@bmc.com)
27 //
|
28 kumpf 1.8 // Modified By: Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)
|
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 /** 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 /// Default constructor.
51 Array();
52
53 /// Copy Constructor.
54 Array(const Array<PEGASUS_ARRAY_T>& x);
55
56 /** Constructs an array with size elements. The elements are
|
57 kumpf 1.11 initialized with their copy constructor.
58 @param size defines the number of elements
|
59 mike 1.5 */
60 Array(Uint32 size);
61
62 /** Constructs an array with size elements. The elements are
|
63 kumpf 1.11 initialized with x.
|
64 mike 1.5 */
65 Array(Uint32 size, const PEGASUS_ARRAY_T& x);
66
67 /** Constructs an array with size elements. The values come from
|
68 kumpf 1.11 the items pointer.
|
69 mike 1.5 */
70 Array(const PEGASUS_ARRAY_T* items, Uint32 size);
71
72 /// Destructs the objects, freeing any resources.
73 ~Array();
74
75 /// Assignment operator.
76 Array<PEGASUS_ARRAY_T>& operator=(const Array<PEGASUS_ARRAY_T>& x);
77
78 /** Clears the contents of the array. After calling this, size()
|
79 kumpf 1.11 returns zero.
|
80 mike 1.5 */
81 void clear();
82
83 /** Reserves memory for capacity elements. Notice that this does not
|
84 kumpf 1.11 change the size of the array (size() returns what it did before).
85 If the capacity of the array is already greater or equal to the
|
86 kumpf 1.14 capacity argument, this method has no effect. After calling
87 reserveCapacity(), getCapacity() returns a value which is greater
88 or equal to the capacity argument.
|
89 kumpf 1.11 @param capacity defines the size that is to be reserved
|
90 mike 1.5 */
|
91 kumpf 1.14 void reserveCapacity(Uint32 capacity);
|
92 mike 1.5
|
93 kumpf 1.19 /** Make the size of the array grow by size elements. The new size will
|
94 kumpf 1.11 be size() + size. The new elements (there are size of them) are
95 initialized with x.
96 @param size defines the number of elements by which the array is to
97 grow.
|
98 mike 1.5 */
99 void grow(Uint32 size, const PEGASUS_ARRAY_T& x);
100
101 /// Swaps the contents of two arrays.
102 void swap(Array<PEGASUS_ARRAY_T>& x);
103
104 /** Returns the number of elements in the array.
105 @return The number of elements in the array.
106 */
|
107 kumpf 1.8 Uint32 size() const;
|
108 mike 1.5
109 /// Returns the capacity of the array.
|
110 kumpf 1.8 Uint32 getCapacity() const;
|
111 mike 1.5
112 /// Returns a pointer to the first element of the array.
|
113 kumpf 1.8 const PEGASUS_ARRAY_T* getData() const;
|
114 mike 1.5
|
115 kumpf 1.18 /** Returns the element indicated by the index argument.
116 @return A reference to the element defined by index so that it may be
|
117 kumpf 1.11 modified.
|
118 mike 1.5 */
|
119 kumpf 1.18 PEGASUS_ARRAY_T& operator[](Uint32 index);
|
120 mike 1.5
121 /** Same as the above method except that this is the version called
|
122 kumpf 1.11 on const arrays. The return value cannot be modified since it
123 is constant.
|
124 mike 1.5 */
|
125 kumpf 1.18 const PEGASUS_ARRAY_T& operator[](Uint32 index) const;
|
126 mike 1.5
127 /** Appends an element to the end of the array. This increases the size
|
128 kumpf 1.11 of the array by one.
129 @param x Element to append.
|
130 mike 1.5 */
131 void append(const PEGASUS_ARRAY_T& x);
132
133 /// Appends size elements at x to the end of this array.
134 void append(const PEGASUS_ARRAY_T* x, Uint32 size);
135
136 /** Appends one array to another. The size of this array grows by the
|
137 kumpf 1.11 size of the other.
138 @param Array to append.
|
139 mike 1.5 */
|
140 kumpf 1.8 void appendArray(const Array<PEGASUS_ARRAY_T>& x);
|
141 mike 1.5
142 /** Appends one element to the beginning of the array. This increases
|
143 kumpf 1.11 the size by one.
144 @param Element to prepend.
|
145 mike 1.5 */
146 void prepend(const PEGASUS_ARRAY_T& x);
147
148 /** Appends size elements to the array starting at the memory address
|
149 kumpf 1.11 given by x. The array grows by size elements.
|
150 mike 1.5 */
151 void prepend(const PEGASUS_ARRAY_T* x, Uint32 size);
152
153 /** Inserts the element at the given index in the array. Subsequent
|
154 kumpf 1.11 elements are moved down. The size of the array grows by one.
|
155 mike 1.5 */
|
156 kumpf 1.18 void insert(Uint32 index, const PEGASUS_ARRAY_T& x);
|
157 mike 1.5
|
158 kumpf 1.18 /** Inserts size elements at x into the array at the given index.
|
159 kumpf 1.11 Subsequent elements are moved down. The size of the array grows
160 by size elements.
|
161 mike 1.5 */
|
162 kumpf 1.18 void insert(Uint32 index, const PEGASUS_ARRAY_T* x, Uint32 size);
|
163 mike 1.5
|
164 kumpf 1.18 /** Removes the element at the given index from the array. The
|
165 kumpf 1.11 size of the array shrinks by one.
|
166 mike 1.5 */
|
167 kumpf 1.18 void remove(Uint32 index);
|
168 mike 1.5
|
169 kumpf 1.18 /** Removes size elements starting at the given index. The size of
|
170 kumpf 1.11 the array shrinks by size elements.
|
171 mike 1.5 */
|
172 kumpf 1.18 void remove(Uint32 index, Uint32 size);
|
173 mike 1.6
|
174 mike 1.5 private:
175
|
176 kumpf 1.8 PEGASUS_ARRAY_T* _data() const;
|
177 mike 1.5
|
178 kumpf 1.11 void* _rep;
|
179 mike 1.5 };
180
|
181 kumpf 1.11 #endif //!defined(Pegasus_ArrayInter_h) || !defined(PEGASUS_ARRAY_T)
|