1 mike 1.2 //%/////////////////////////////////////////////////////////////////////////////
|
2 mike 1.1 //
3 // Copyright (c) 2000 The Open Group, BMC Software, Tivoli Systems, IBM
4 //
5 // Permission is hereby granted, free of charge, to any person obtaining a
6 // copy of this software and associated documentation files (the "Software"),
7 // to deal in the Software without restriction, including without limitation
8 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 // and/or sell copies of the Software, and to permit persons to whom the
10 // Software is furnished to do so, subject to the following conditions:
11 //
12 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
15 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
17 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
18 // DEALINGS IN THE SOFTWARE.
19 //
|
20 mike 1.2 //==============================================================================
|
21 mike 1.1 //
|
22 mike 1.2 // Author: Mike Brasher (mbrasher@bmc.com)
|
23 mike 1.1 //
|
24 mike 1.2 // Modified By:
|
25 mike 1.1 //
|
26 mike 1.2 //%/////////////////////////////////////////////////////////////////////////////
|
27 mike 1.1
28 #ifndef Pegasus_InstanceIndexFile_h
29 #define Pegasus_InstanceIndexFile_h
30
31 #include <Pegasus/Common/Config.h>
32 #include <Pegasus/Common/String.h>
33 #include <Pegasus/Common/Exception.h>
|
34 mike 1.3 #include <Pegasus/Common/CIMReference.h>
|
35 mike 1.1
36 PEGASUS_NAMESPACE_BEGIN
37
38 /** This class manages access to an "instance index file" which maps
39 instance names to indexes. Lines of this file have the following form:
40
41 <pre>
|
42 mike 1.3 <hash-code> ClassName.key1=value1,...,keyN=valueN Index
|
43 mike 1.1 </pre>
44
|
45 mike 1.3 Where the hash-code is an eight digit hex number, the instance name is
46 a CIM style object name, and the index is a positive integer (non-zero).
47 Here's an example:
|
48 mike 1.1
49 <pre>
|
50 mike 1.3 A6B275A9 Employee.ssn=444332222 1
51 A6BA08BE Employee.ssn=555667777 3
|
52 mike 1.1 </pre>
53
54 Each instance in Pegasus is represented as a disk file containing the
55 CIM/XML encoding of the instance. The name of the file has this form:
56
57 <pre>
58 ClassName.Index
59 </pre>
60
61 Here's an example:
62
63 <pre>
64 Employee.3
65 </pre>
66
|
67 mike 1.3 An instance can be obtained from an instance name by searching all entries
68 in the index file with the same hash code (to account for hash clashes),
69 comparing the instance names, and then forming the name of the instance
70 file itself from the index.
|
71 mike 1.1
72 Methods are provided for managing the instance index file: adding,
73 removing, and modifying instance names.
74 */
75 class PEGASUS_REPOSITORY_LINKAGE InstanceIndexFile
76 {
77 public:
78
79 /** Search the index file for the given instance name. Sets the index
80 parameter to the corresponding index. Returns true on success.
81 */
82 static Boolean lookup(
83 const String& path,
|
84 mike 1.3 const CIMReference& instanceName,
|
85 mike 1.1 Uint32& index);
86
87 /** Inserts a new entry into the instance file. The index parameter is
88 set to the index of the entry. This method assumes that the keys in
89 the instance name are in sorted order. This must be done prior to
90 calling the method. Return true on success.
91 */
92 static Boolean insert(
93 const String& path,
|
94 mike 1.3 const CIMReference& instanceName,
|
95 mike 1.1 Uint32& index);
96
97 /** Remove the entry with the given instance name. Returns true on success.
98 */
99 static Boolean remove(
100 const String& path,
|
101 mike 1.3 const CIMReference& instanceName);
|
102 mike 1.4
103 /** Get instance names of the given class. Append them to the given
104 array (do not clear the array first).
105 */
106 static Boolean appendInstanceNamesTo(
107 const String& path,
108 Array<CIMReference>& instanceNames,
109 Array<Uint32>& indices);
|
110 mike 1.1 };
111
112 PEGASUS_NAMESPACE_END
113
114 #endif /* Pegasus_InstanceIndexFile_h */
|