(file) Return to CIMRepository.h CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / repositories

  1 karl  1.1.2.1 //%/////////////////////////////////////////////////////////////////////////////
  2               //
  3               // Copyright (c) 2000, 2001 The Open group, BMC Software, Tivoli Systems, IBM
  4               //
  5               // Permission is hereby granted, free of charge, to any person obtaining a copy
  6               // of this software and associated documentation files (the "Software"), to
  7               // deal in the Software without restriction, including without limitation the
  8               // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9               // sell copies of the Software, and to permit persons to whom the Software is
 10               // furnished to do so, subject to the following conditions:
 11               //
 12               // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 13               // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
 14               // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 15               // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 16               // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 17               // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 18               // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 19               // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 20               //
 21               //==============================================================================
 22 karl  1.1.2.1 //
 23               // Author: Mike Brasher (mbrasher@bmc.com)
 24               //
 25               // Modified By: Jenny Yu, Hewlett-Packard Company (jenny_yu@hp.com)
 26               //              Yi Zhou, Hewlett-Packard Company (yi_zhou@hp.com)
 27               //              Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)
 28               //
 29               //%/////////////////////////////////////////////////////////////////////////////
 30               
 31               #ifndef PegasusRepository_Repository_h
 32               #define PegasusRepository_Repository_h
 33               
 34               #include <Pegasus/Common/Config.h>
 35               #include <Pegasus/Common/CIMClass.h>
 36               #include <Pegasus/Common/CIMObject.h>
 37               #include <Pegasus/Common/CIMInstance.h>
 38               #include <Pegasus/Common/CIMNamedInstance.h>
 39               #include <Pegasus/Common/CIMPropertyList.h>
 40               #include <Pegasus/Common/CIMQualifierDecl.h>
 41               #include <Pegasus/Config/ConfigManager.h>
 42               #include <Pegasus/Repository/NameSpaceManager.h>
 43 karl  1.1.2.1 
 44               PEGASUS_NAMESPACE_BEGIN
 45               
 46               class RepositoryDeclContext;
 47               
 48               /** This class provides a simple implementation of a CIM repository.
 49               */
 50               class PEGASUS_REPOSITORY_LINKAGE CIMRepository
 51               {
 52               public:
 53               
 54                   /// Constructor
 55                   CIMRepository(const String& repositoryRoot);
 56               
 57                   /// Descructor
 58                   virtual ~CIMRepository();
 59               
 60                   /// virtual class CIMClass. From the operations class
 61                   virtual CIMClass getClass(
 62                       const String& nameSpace,
 63                       const String& className,
 64 karl  1.1.2.1         Boolean localOnly = true,
 65                       Boolean includeQualifiers = true,
 66                       Boolean includeClassOrigin = false,
 67                       const CIMPropertyList& propertyList = CIMPropertyList());
 68               
 69                   /// getInstance
 70                   virtual CIMInstance getInstance(
 71                       const String& nameSpace,
 72                       const CIMReference& instanceName,
 73                       Boolean localOnly = true,
 74                       Boolean includeQualifiers = false,
 75                       Boolean includeClassOrigin = false,
 76                       const CIMPropertyList& propertyList = CIMPropertyList());
 77               
 78                   /// deleteClass
 79                   virtual void deleteClass(
 80                       const String& nameSpace,
 81                       const String& className);
 82               
 83                   /// deleteInstance
 84                   virtual void deleteInstance(
 85 karl  1.1.2.1         const String& nameSpace,
 86                       const CIMReference& instanceName);
 87               
 88                   /// createClass
 89                   virtual void createClass(
 90                       const String& nameSpace,
 91                       const CIMClass& newClass);
 92               
 93                   /// createInstance
 94                   virtual CIMReference createInstance(
 95                       const String& nameSpace,
 96                       const CIMInstance& newInstance);
 97               
 98                   /// modifyClass
 99                   virtual void modifyClass(
100                       const String& nameSpace,
101                       const CIMClass& modifiedClass);
102               
103                   /// modifyInstance
104                   virtual void modifyInstance(
105                       const String& nameSpace,
106 karl  1.1.2.1         const CIMNamedInstance& modifiedInstance,
107                       Boolean includeQualifiers = true,
108                       const CIMPropertyList& propertyList = CIMPropertyList());
109               
110                   /// enumerateClasses
111                   virtual Array<CIMClass> enumerateClasses(
112                       const String& nameSpace,
113                       const String& className = String::EMPTY,
114                       Boolean deepInheritance = false,
115                       Boolean localOnly = true,
116                       Boolean includeQualifiers = true,
117                       Boolean includeClassOrigin = false);
118               
119                   /// enumerateClassNames
120                   virtual Array<String> enumerateClassNames(
121                       const String& nameSpace,
122                       const String& className = String::EMPTY,
123                       Boolean deepInheritance = false);
124               
125                   /// enumerateInstances
126                   virtual Array<CIMNamedInstance> enumerateInstances(
127 karl  1.1.2.1         const String& nameSpace,
128                       const String& className,
129                       Boolean deepInheritance = true,
130                       Boolean localOnly = true,
131                       Boolean includeQualifiers = false,
132                       Boolean includeClassOrigin = false,
133                       const CIMPropertyList& propertyList = CIMPropertyList());
134               
135                   /// enumerateInstanceNames
136                   virtual Array<CIMReference> enumerateInstanceNames(
137                       const String& nameSpace,
138                       const String& className);
139               
140                   /// execQuery
141                   virtual Array<CIMInstance> execQuery(
142                       const String& queryLanguage,
143                       const String& query) ;
144               
145                   /// associators
146                   virtual Array<CIMObjectWithPath> associators(
147                       const String& nameSpace,
148 karl  1.1.2.1         const CIMReference& objectName,
149                       const String& assocClass = String::EMPTY,
150                       const String& resultClass = String::EMPTY,
151                       const String& role = String::EMPTY,
152                       const String& resultRole = String::EMPTY,
153                       Boolean includeQualifiers = false,
154                       Boolean includeClassOrigin = false,
155                       const CIMPropertyList& propertyList = CIMPropertyList());
156               
157                   /// associateNames
158                   virtual Array<CIMReference> associatorNames(
159                       const String& nameSpace,
160                       const CIMReference& objectName,
161                       const String& assocClass = String::EMPTY,
162                       const String& resultClass = String::EMPTY,
163                       const String& role = String::EMPTY,
164                       const String& resultRole = String::EMPTY);
165               
166                   /// references
167                   virtual Array<CIMObjectWithPath> references(
168                       const String& nameSpace,
169 karl  1.1.2.1         const CIMReference& objectName,
170                       const String& resultClass = String::EMPTY,
171                       const String& role = String::EMPTY,
172                       Boolean includeQualifiers = false,
173                       Boolean includeClassOrigin = false,
174                       const CIMPropertyList& propertyList = CIMPropertyList());
175               
176                   /// referenceNames
177                   virtual Array<CIMReference> referenceNames(
178                       const String& nameSpace,
179                       const CIMReference& objectName,
180                       const String& resultClass = String::EMPTY,
181                       const String& role = String::EMPTY);
182               
183                   /// getProperty
184                   virtual CIMValue getProperty(
185                       const String& nameSpace,
186                       const CIMReference& instanceName,
187                       const String& propertyName);
188               
189                   /// setProperty
190 karl  1.1.2.1     virtual void setProperty(
191                       const String& nameSpace,
192                       const CIMReference& instanceName,
193                       const String& propertyName,
194                       const CIMValue& newValue = CIMValue());
195               
196                   /// getQualifier
197                   virtual CIMQualifierDecl getQualifier(
198                       const String& nameSpace,
199                       const String& qualifierName);
200               
201                   /// setQualifier
202                   virtual void setQualifier(
203                       const String& nameSpace,
204                       const CIMQualifierDecl& qualifierDecl);
205               
206                   /// virtual deleteQualifier
207                   virtual void deleteQualifier(
208                       const String& nameSpace,
209                       const String& qualifierName);
210               
211 karl  1.1.2.1     /// enumerateQualifiers
212                   virtual Array<CIMQualifierDecl> enumerateQualifiers(
213                       const String& nameSpace);
214               
215                   /// invokeMethod
216                   virtual CIMValue invokeMethod(
217                       const String& nameSpace,
218                       const CIMReference& instanceName,
219                       const String& methodName,
220                       const Array<CIMValue>& inParameters,
221                       Array<CIMValue>& outParameters);
222               
223                   /** CIMMethod createNameSpace - Creates a new namespace in the repository
224                       @param String with the name of the namespace
225                       @exception - Throws "Already_Exists if the Namespace exits.
226                       Throws "CannotCreateDirectory" if there are problems in the
227                       creation.
228                   */
229                   void createNameSpace(const String& nameSpace);
230               
231                   /** CIMMethod enumerateNameSpaces - Get all of the namespaces in the
232 karl  1.1.2.1         repository. \Ref{NAMESPACE}
233                       @return Array of strings with the namespaces
234                   */
235                   virtual Array<String> enumerateNameSpaces() const;
236               
237                   /** CIMMethod deleteNameSpace - Deletes a namespace in the repository.
238                       The deleteNameSpace method will only delete a namespace if there are
239                       no classed defined in the namespace.  Today this is a Pegasus
240                       characteristics and not defined as part of the DMTF standards.
241                       @param String with the name of the namespace
242                       @exception - Throws NoSuchDirectory if the Namespace does not exist.
243                   */
244                   void deleteNameSpace(const String& nameSpace);
245               
246                   /** CIMMethod setDeclContext - allows the Declaration Context set
247                       by default in the CIMRepository constructor to be overridden.
248                       This is useful, for example, when a compiler wants to check syntax
249                       without actually adding to the repository.
250                   */
251                   void setDeclContext(RepositoryDeclContext *context);
252               
253 karl  1.1.2.1     /** Indicates whether instance operations that do not have a provider
254                       registered should be served by this repository.
255                   */
256                   Boolean isDefaultInstanceProvider()
257                   {
258                       return _isDefaultInstanceProvider;
259                   }
260               
261                   /** Indicates the name by which this repository explicitly registers as
262                       an instance provider.
263                   */
264                   const String& getProviderName()
265                   {
266                       return _providerName;
267                   }
268               
269               private:
270               
271                   void _createAssocInstEntries(
272                       const String& nameSpace,
273                       const CIMConstClass& cimClass,
274 karl  1.1.2.1         const CIMInstance& cimInstance,
275                       const CIMReference& instanceName);
276               
277                   void _createAssocClassEntries(
278                       const String& nameSpace,
279                       const CIMConstClass& assocClass);
280               
281                   /** Returns the index (or byte location) and size of the instance
282                       record in the instance file for a given instance.  Returns true
283                       if successful.  Returns false if the instance cannot be found.
284               
285                       @param   nameSpace      the namespace of the instance
286                       @param   instanceName   the name of the instance
287                       @param   className      the name of the class
288                       @param   size           the size of the instance record found
289                       @param   index          the byte positon of the instance record found
290                       @param   searchSuper    if true, search all superclasses 
291                    
292                       @return  true           if the instance is found
293                                false          if the instance cannot be found
294                    */
295 karl  1.1.2.1     Boolean _getInstanceIndex(
296                       const String& nameSpace,
297                       const CIMReference& instanceName,
298                       String& className,
299                       Uint32& size,
300                       Uint32& index,
301                       Boolean searchSuperClasses = false) const;
302               
303                   /** Returns the file path of the instance index file.
304               
305                       @param   nameSpace      the namespace of the instance
306                       @param   className      the name of the class
307               
308                       @return  a string containing the index file path
309                    */
310                   String _getIndexFilePath(
311                       const String& nameSpace,
312                       const String& className) const;
313               
314                   /** Returns the file path of the instance file.
315               
316 karl  1.1.2.1         @param   nameSpace      the namespace of the instance
317                       @param   className      the name of the class
318               
319                       @return  a string containing the instance file path
320                    */
321                   String _getInstanceFilePath(
322                       const String& nameSpace,
323                       const String& className) const;
324               
325                   /** Saves an instance object from memory to disk file.  The byte
326                       position and the size of the newly inserted instance record are
327                       returned.  Returns true on success.
328               
329                       @param   path      the file path of the instance file
330                       @param   object    the CIMInstance object to be saved
331                       @param   index     the byte positon of the saved instance record
332                       @param   size      the size of the saved instance record
333               
334                       @return  true      if successful
335                                false     if an error occurs in saving the instance to file
336                    */
337 karl  1.1.2.1     Boolean _saveInstance(
338                       const String& path,
339                       const CIMInstance& object,
340                       Uint32& index,
341                       Uint32& size);
342               
343                   /** loads an instance object from disk to memory.  The caller passes 
344                       the byte position and the size of the instance record to be loaded.
345                       Returns true on success.
346               
347                       @param   path      the file path of the instance file
348                       @param   object    the CIMInstance object to be returned
349                       @param   index     the byte positon of the instance record
350                       @param   size      the size of the instance record
351                       @param   data      the buffer to hold the instance data
352               
353                       @return  true      if successful
354                                false     if an error occurs in loading the instance from file
355                    */
356                   Boolean _loadInstance(
357                       const String& path,
358 karl  1.1.2.1         CIMInstance& object,
359                       Uint32 index,
360                       Uint32 size);
361               
362                   /** loads all the instance objects from disk to memeory.  Returns true
363                       on success.
364               
365                       @param   nameSpace      the namespace of the instances to be loaded 
366                       @param   className      the class of the instances to be loaded
367                       @param   namedInstances an array of CIMNamedInstance objects to which
368                                               the loaded instances are appended
369               
370                       @return  true      if successful
371                                false     if an error occurs in loading the instances
372                    */
373                   Boolean _loadAllInstances(
374                       const String& nameSpace,
375                       const String& className,
376                       Array<CIMNamedInstance>& namedInstances);
377               
378                   /** Modifies an instance object saved in the disk file.  The byte position
379 karl  1.1.2.1         and the size of the newly added instance record are returned.  Returns
380                       true on success.
381               
382                       @param   path      the file path of the instance file
383                       @param   object    the modified CIMInstance object
384                       @param   oldIndex  the byte positon of the old instance record
385                       @param   oldSize   the size of the old instance record
386                       @param   newIndex  the byte positon of the new instance record
387                       @param   newSize   the size of the new instance record
388               
389                       @return  true      if successful
390                                false     if an error occurs in modifying the instance
391                    */
392                   Boolean _modifyInstance(
393                       const String& path,
394                       const CIMInstance& object,
395                       Uint32 oldIndex,
396                       Uint32 oldSize,
397                       Uint32& newIndex,
398                       Uint32& newSize);
399               
400 karl  1.1.2.1     /** Renames the temporary instance and instance index files back to the
401                       original files.  The temporary files were created for an insert,
402                       remove, or modify operation (to avoid data inconsistency between
403                       the two files in case of unexpected system termination or failure).
404                       This method is called after a successful insert, remove, or modify
405                       operation on BOTH the index file and the instance file.  Returns
406                       true on success.
407               
408                       @param   indexFilePath   the file path of the instance index file
409                       @param   instancePath    the file path of the instance file
410               
411                       @return  true      if successful
412                                false     if an error occurs in removing the original files
413                                          or renaming the temporary files.
414                    */
415                   Boolean _renameTempInstanceAndIndexFiles(
416                       const String& indexFilePath,
417                       const String& instanceFilePath);
418               
419                   String _repositoryRoot;
420                   NameSpaceManager _nameSpaceManager;
421 karl  1.1.2.1 
422                   // These must be initialized in the constructor using values from the
423                   // ConfigManager.
424                   Boolean _isDefaultInstanceProvider;
425                   String _providerName;
426               
427               protected:
428                   RepositoryDeclContext* _context;
429               };
430               
431               PEGASUS_NAMESPACE_END
432               
433               #endif /* PegasusRepository_Repository_h */
434               

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2