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

  1 mike  1.1.2.1 //%2006////////////////////////////////////////////////////////////////////////
  2               //
  3               // 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               // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
  8               // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
  9               // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 10               // EMC Corporation; VERITAS Software Corporation; The Open Group.
 11               // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 12               // EMC Corporation; Symantec Corporation; The Open Group.
 13               //
 14               // Permission is hereby granted, free of charge, to any person obtaining a copy
 15               // of this software and associated documentation files (the "Software"), to
 16               // deal in the Software without restriction, including without limitation the
 17               // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 18               // sell copies of the Software, and to permit persons to whom the Software is
 19               // furnished to do so, subject to the following conditions:
 20               //
 21               // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 22 mike  1.1.2.1 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
 23               // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 24               // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 25               // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 26               // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 27               // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 28               // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 29               //
 30               //==============================================================================
 31               //
 32               //%/////////////////////////////////////////////////////////////////////////////
 33               
 34               #ifndef Pegasus_DefaultRepository_h
 35               #define Pegasus_DefaultRepository_h
 36               
 37               #include <Pegasus/Common/Config.h>
 38               #include <Pegasus/Common/CIMClass.h>
 39               #include <Pegasus/Common/CIMObject.h>
 40               #include <Pegasus/Common/CIMInstance.h>
 41               #include <Pegasus/Common/CIMPropertyList.h>
 42               #include <Pegasus/Common/CIMQualifierDecl.h>
 43 mike  1.1.2.1 #include <Pegasus/Common/ContentLanguageList.h>
 44               #include <Pegasus/Config/ConfigManager.h>
 45               #include <Pegasus/Repository/NameSpaceManager.h>
 46               #include <Pegasus/Repository/Linkage.h>
 47               #include <Pegasus/Common/ReadWriteSem.h>
 48               #include <Pegasus/Common/ObjectStreamer.h>
 49               #include <Pegasus/Repository/Repository.h>
 50               
 51               PEGASUS_NAMESPACE_BEGIN
 52               
 53               class RepositoryDeclContext;
 54               class compilerDeclContext;
 55               
 56               /** This class provides a simple implementation of a CIM repository.
 57                   Concurrent access is controlled by an internal lock.
 58               */
 59               class PEGASUS_REPOSITORY_LINKAGE DefaultRepository : public Repository
 60               {
 61               public:
 62               
 63                   enum DefaultRepositoryMode
 64 mike  1.1.2.1     {
 65                       MODE_DEFAULT = 0,
 66                       MODE_XML = 1,
 67                       MODE_BIN = 2,
 68                       MODE_COMPRESSED = 4
 69                   };
 70               
 71                   /// Constructor
 72                   DefaultRepository(
 73                       const String& repositoryRoot,
 74                       Uint32 repositoryMode);
 75               
 76                   /// Descructor
 77                   virtual ~DefaultRepository();
 78               
 79                   /// getClass
 80                   virtual CIMClass getClass(
 81                       bool lock,
 82                       const CIMNamespaceName& nameSpace,
 83                       const CIMName& className,
 84                       Boolean localOnly,
 85 mike  1.1.2.1         Boolean includeQualifiers,
 86                       Boolean includeClassOrigin,
 87                       const CIMPropertyList& propertyList);
 88               
 89                   /// getInstance
 90                   virtual CIMInstance getInstance(
 91                       bool lock,
 92                       const CIMNamespaceName& nameSpace,
 93                       const CIMObjectPath& instanceName,
 94                       Boolean localOnly,
 95                       Boolean includeQualifiers,
 96                       Boolean includeClassOrigin,
 97                       const CIMPropertyList& propertyList);
 98               
 99                   /// deleteClass
100                   virtual void deleteClass(
101                       bool lock,
102                       const CIMNamespaceName& nameSpace,
103                       const CIMName& className);
104               
105                   /// deleteInstance
106 mike  1.1.2.1     virtual void deleteInstance(
107                       bool lock,
108                       const CIMNamespaceName& nameSpace,
109                       const CIMObjectPath& instanceName);
110               
111                   /// createClass
112                   virtual void createClass(
113                       bool lock,
114                       const CIMNamespaceName& nameSpace,
115                       const CIMClass& newClass,
116                       const ContentLanguageList& contentLangs);
117               
118                   /// createInstance
119                   virtual CIMObjectPath createInstance(
120                       bool lock,
121                       const CIMNamespaceName& nameSpace,
122                       const CIMInstance& newInstance,
123                       const ContentLanguageList& contentLangs);
124               
125                   /// modifyClass
126                   virtual void modifyClass(
127 mike  1.1.2.1         bool lock,
128                       const CIMNamespaceName& nameSpace,
129                       const CIMClass& modifiedClass,
130                       const ContentLanguageList& contentLangs);
131               
132                   /// modifyInstance
133                   virtual void modifyInstance(
134                       bool lock,
135                       const CIMNamespaceName& nameSpace,
136                       const CIMInstance& modifiedInstance,
137                       Boolean includeQualifiers,
138                       const CIMPropertyList& propertyList,
139                       const ContentLanguageList& contentLangs);
140               
141                   /// enumerateClasses
142                   virtual Array<CIMClass> enumerateClasses(
143                       bool lock,
144                       const CIMNamespaceName& nameSpace,
145                       const CIMName& className,
146                       Boolean deepInheritance,
147                       Boolean localOnly,
148 mike  1.1.2.1         Boolean includeQualifiers,
149                       Boolean includeClassOrigin);
150               
151                   /// enumerateClassNames
152                   virtual Array<CIMName> enumerateClassNames(
153                       bool lock,
154                       const CIMNamespaceName& nameSpace,
155                       const CIMName& className,
156                       Boolean deepInheritance);
157               
158                   /**
159                       Enumerates the instances of the specified class and its subclasses.
160                       This method mimics the client behavior for the EnumerateInstances
161                       operation, but of course it can only return the instances that reside
162                       in the repository.  This method does not perform deepInheritance
163                       filtering regardless of the value given for that parameter.
164               
165                       This method is useful mainly for testing purposes, and should not be
166                       relied upon for complete results in a CIM Server environment.
167                   */
168                   virtual Array<CIMInstance> enumerateInstancesForSubtree(
169 mike  1.1.2.1         bool lock,
170                       const CIMNamespaceName& nameSpace,
171                       const CIMName& className,
172                       Boolean deepInheritance,
173                       Boolean localOnly,
174                       Boolean includeQualifiers,
175                       Boolean includeClassOrigin,
176                       const CIMPropertyList& propertyList);
177               
178                   /**
179                       Enumerates the instances of just the specified class.
180                       This method mimics the provider behavior for the EnumerateInstances
181                       operation.
182                   */
183                   virtual Array<CIMInstance> enumerateInstancesForClass(
184                       bool lock,
185                       const CIMNamespaceName& nameSpace,
186                       const CIMName& className,
187                       Boolean localOnly,
188                       Boolean includeQualifiers,
189                       Boolean includeClassOrigin,
190 mike  1.1.2.1         const CIMPropertyList& propertyList);
191               
192               
193                   /**
194                       Enumerates the names of the instances of the specified class and its
195                       subclasses.  This method mimics the client behavior for the
196                       EnumerateInstanceNames operation, but of course it can only return
197                       the names of the instances that reside in the repository.
198               
199                       This method is useful mainly for testing purposes, and should not be
200                       relied upon for complete results in a CIM Server environment.
201               
202                       @param nameSpace The namespace in which className resides.
203                       @param className The name the class for which to retrieve the instance
204                           names.
205                       @return An Array of CIMObjectPath objects containing the names of the
206                           instances of the specified class in the specified namespace.
207                   */
208                   virtual Array<CIMObjectPath> enumerateInstanceNamesForSubtree(
209                       bool lock,
210                       const CIMNamespaceName& nameSpace,
211 mike  1.1.2.1         const CIMName& className);
212               
213                   /**
214                       Enumerates the names of the instances of just the specified class.
215                       This method mimics the provider behavior for the EnumerateInstanceNames
216                       operation.
217               
218                       @param nameSpace The namespace in which className resides.
219                       @param className The name the class for which to retrieve the instance
220                           names.
221                       @return An Array of CIMObjectPath objects containing the names of the
222                           instances of the specified class in the specified namespace.
223                   */
224                   virtual Array<CIMObjectPath> enumerateInstanceNamesForClass(
225                       bool lock,
226                       const CIMNamespaceName& nameSpace,
227                       const CIMName& className);
228               
229               
230                   /// execQuery
231                   virtual Array<CIMInstance> execQuery(
232 mike  1.1.2.1         bool lock,
233                       const String& queryLanguage,
234                       const String& query) ;
235               
236                   /// associators
237                   virtual Array<CIMObject> associators(
238                       bool lock,
239                       const CIMNamespaceName& nameSpace,
240                       const CIMObjectPath& objectName,
241                       const CIMName& assocClass,
242                       const CIMName& resultClass,
243                       const String& role,
244                       const String& resultRole,
245                       Boolean includeQualifiers,
246                       Boolean includeClassOrigin,
247                       const CIMPropertyList& propertyList);
248               
249                   /// associatorNames
250                   virtual Array<CIMObjectPath> associatorNames(
251                       bool lock,
252                       const CIMNamespaceName& nameSpace,
253 mike  1.1.2.1         const CIMObjectPath& objectName,
254                       const CIMName& assocClass,
255                       const CIMName& resultClass,
256                       const String& role,
257                       const String& resultRole);
258               
259                   /// references
260                   virtual Array<CIMObject> references(
261                       bool lock,
262                       const CIMNamespaceName& nameSpace,
263                       const CIMObjectPath& objectName,
264                       const CIMName& resultClass,
265                       const String& role,
266                       Boolean includeQualifiers,
267                       Boolean includeClassOrigin,
268                       const CIMPropertyList& propertyList);
269               
270                   /// referenceNames
271                   virtual Array<CIMObjectPath> referenceNames(
272                       bool lock,
273                       const CIMNamespaceName& nameSpace,
274 mike  1.1.2.1         const CIMObjectPath& objectName,
275                       const CIMName& resultClass,
276                       const String& role);
277               
278                   /// getProperty
279                   virtual CIMValue getProperty(
280                       bool lock,
281                       const CIMNamespaceName& nameSpace,
282                       const CIMObjectPath& instanceName,
283                       const CIMName& propertyName);
284               
285                   /// setProperty
286                   virtual void setProperty(
287                       bool lock,
288                       const CIMNamespaceName& nameSpace,
289                       const CIMObjectPath& instanceName,
290                       const CIMName& propertyName,
291                       const CIMValue& newValue,
292                       const ContentLanguageList& contentLangs);
293               
294                   /// getQualifier
295 mike  1.1.2.1     virtual CIMQualifierDecl getQualifier(
296                       bool lock,
297                       const CIMNamespaceName& nameSpace,
298                       const CIMName& qualifierName);
299               
300                   /// setQualifier
301                   virtual void setQualifier(
302                       bool lock,
303                       const CIMNamespaceName& nameSpace,
304                       const CIMQualifierDecl& qualifierDecl,
305                       const ContentLanguageList& contentLangs);
306               
307                   /// deleteQualifier
308                   virtual void deleteQualifier(
309                       bool lock,
310                       const CIMNamespaceName& nameSpace,
311                       const CIMName& qualifierName);
312               
313                   /// enumerateQualifiers
314                   virtual Array<CIMQualifierDecl> enumerateQualifiers(
315                       bool lock,
316 mike  1.1.2.1         const CIMNamespaceName& nameSpace);
317               
318                   typedef HashTable <String, String, EqualNoCaseFunc, HashLowerCaseFunc>
319                       NameSpaceAttributes;
320               
321                   /** CIMMethod createNameSpace - Creates a new namespace in the repository
322                       @param String with the name of the namespace
323                       @exception - Throws "Already_Exists if the Namespace exits.
324                       Throws "CannotCreateDirectory" if there are problems in the
325                       creation.
326                   */
327               
328                   virtual void createNameSpace(
329                       bool lock,
330                       const CIMNamespaceName& nameSpace,
331                       const NameSpaceAttributes& attributes);
332               
333                   virtual void modifyNameSpace(
334                       bool lock,
335                       const CIMNamespaceName& nameSpace,
336                       const NameSpaceAttributes& attributes);
337 mike  1.1.2.1 
338                   /** CIMMethod enumerateNameSpaces - Get all of the namespaces in the
339                       repository. \Ref{NAMESPACE}
340                       @return Array of strings with the namespaces
341                   */
342                   virtual Array<CIMNamespaceName> enumerateNameSpaces(
343                       bool lock) const;
344               
345                   /** CIMMethod deleteNameSpace - Deletes a namespace in the repository.
346                       The deleteNameSpace method will only delete a namespace if there are
347                       no classed defined in the namespace.  Today this is a Pegasus
348                       characteristics and not defined as part of the DMTF standards.
349                       @param String with the name of the namespace
350                       @exception - Throws NoSuchDirectory if the Namespace does not exist.
351                   */
352                   virtual void deleteNameSpace(
353                       bool lock,
354                       const CIMNamespaceName& nameSpace);
355               
356                   virtual Boolean getNameSpaceAttributes(
357                       bool lock,
358 mike  1.1.2.1         const CIMNamespaceName& nameSpace,
359                       NameSpaceAttributes& attributes);
360               
361                   ////////////////////////////////////////////////////////////////////////////
362               
363                   /** CIMMethod setDeclContext - allows the Declaration Context set
364                       by default in the DefaultRepository constructor to be overridden.
365                       This is useful, for example, when a compiler wants to check syntax
366                       without actually adding to the repository.
367                   */
368                   void setDeclContext(
369                       bool lock,
370                       RepositoryDeclContext* context);
371               
372                   /** Indicates whether instance operations that do not have a provider
373                       registered should be served by this repository.
374                   */
375                   virtual Boolean isDefaultInstanceProvider(
376                       bool lock)
377                   {
378                       return _isDefaultInstanceProvider;
379 mike  1.1.2.1     }
380               
381                   /** Get subclass names of the given class in the given namespace.
382                       @param nameSpaceName
383                       @param className - class whose subclass names will be gotten. If
384                           className is empty, all classnames are returned.
385                       @param deepInheritance - if true all descendent classes of class
386                           are returned. If className is empty, only root classes are returned.
387                       @param subClassNames - output argument to hold subclass names.
388                       @exception CIMException(CIM_ERR_INVALID_CLASS)
389                   */
390                   virtual void getSubClassNames(
391                       bool lock,
392                       const CIMNamespaceName& nameSpaceName,
393                       const CIMName& className,
394                       Boolean deepInheritance,
395                       Array<CIMName>& subClassNames) const;
396               
397                   /** Get the names of all superclasses (direct and indirect) of this
398                       class.
399                   */
400 mike  1.1.2.1     virtual void getSuperClassNames(
401                       bool lock,
402                       const CIMNamespaceName& nameSpaceName,
403                       const CIMName& className,
404                       Array<CIMName>& superClassNames) const;
405               
406                   virtual Boolean isRemoteNameSpace(
407                       bool lock,
408                       const CIMNamespaceName& nameSpaceName,
409                       String& remoteInfo);
410               
411               #ifdef PEGASUS_DEBUG
412                   virtual void DisplayCacheStatistics(
413                       bool lock);
414               #endif
415               
416               private:
417               
418                   /**
419                       Searches for incomplete instance transactions for all classes in all
420                       namespaces.  Restores instance index and data files to void an
421 mike  1.1.2.1         incomplete operation.  If no incomplete instance transactions are
422                       outstanding, this method has no effect.
423                    */
424                   void _rollbackIncompleteTransactions();
425               
426                   void _createAssocInstEntries(
427                       const CIMNamespaceName& nameSpace,
428                       const CIMConstClass& cimClass,
429                       const CIMInstance& cimInstance,
430                       const CIMObjectPath& instanceName);
431               
432                   void _createAssocClassEntries(
433                       const CIMNamespaceName& nameSpace,
434                       const CIMConstClass& assocClass);
435               
436                   /**
437                       Checks whether an instance with the specified key values exists in the
438                       class hierarchy of the specified class.
439               
440                       @param   nameSpace      the namespace of the instance
441                       @param   instanceName   the name of the instance
442 mike  1.1.2.1 
443                       @return  true           if the instance is found
444                                false          if the instance cannot be found
445                    */
446                   Boolean _checkInstanceAlreadyExists(
447                       const CIMNamespaceName& nameSpace,
448                       const CIMObjectPath& instanceName) const;
449               
450                   /** Returns the file path of the instance index file.
451               
452                       @param   nameSpace      the namespace of the instance
453                       @param   className      the name of the class
454               
455                       @return  a string containing the index file path
456                    */
457                   String _getInstanceIndexFilePath(
458                       const CIMNamespaceName& nameSpace,
459                       const CIMName& className) const;
460               
461                   /** Returns the file path of the instance file.
462               
463 mike  1.1.2.1         @param   nameSpace      the namespace of the instance
464                       @param   className      the name of the class
465               
466                       @return  a string containing the instance file path
467                    */
468                   String _getInstanceDataFilePath(
469                       const CIMNamespaceName& nameSpace,
470                       const CIMName& className) const;
471               
472                   /** Saves an instance object from memory to disk file.  The byte
473                       position and the size of the newly inserted instance record are
474                       returned.  Returns true on success.
475               
476                       @param   path      the file path of the instance file
477                       @param   object    the CIMInstance object to be saved
478                       @param   index     the byte positon of the saved instance record
479                       @param   size      the size of the saved instance record
480               
481                       @return  true      if successful
482                                false     if an error occurs in saving the instance to file
483                    */
484 mike  1.1.2.1     Boolean _saveInstance(
485                       const String& path,
486                       const CIMInstance& object,
487                       Uint32& index,
488                       Uint32& size);
489               
490                   /** loads an instance object from disk to memory.  The caller passes
491                       the byte position and the size of the instance record to be loaded.
492                       Returns true on success.
493               
494                       @param   path      the file path of the instance file
495                       @param   object    the CIMInstance object to be returned
496                       @param   index     the byte positon of the instance record
497                       @param   size      the size of the instance record
498                       @param   data      the buffer to hold the instance data
499               
500                       @return  true      if successful
501                                false     if an error occurs in loading the instance from file
502                    */
503                   Boolean _loadInstance(
504                       const String& path,
505 mike  1.1.2.1         CIMInstance& object,
506                       Uint32 index,
507                       Uint32 size);
508               
509                   /** loads all the instance objects from disk to memeory.  Returns true
510                       on success.
511               
512                       @param   nameSpace      the namespace of the instances to be loaded
513                       @param   className      the class of the instances to be loaded
514                       @param   namedInstances an array of CIMInstance objects to which
515                                               the loaded instances are appended
516               
517                       @return  true      if successful
518                                false     if an error occurs in loading the instances
519                    */
520                   Boolean _loadAllInstances(
521                       const CIMNamespaceName& nameSpace,
522                       const CIMName& className,
523                       Array<CIMInstance>& namedInstances);
524               
525                   /** Modifies an instance object saved in the disk file.  The byte position
526 mike  1.1.2.1         and the size of the newly added instance record are returned.  Returns
527                       true on success.
528               
529                       @param   path      the file path of the instance file
530                       @param   object    the modified CIMInstance object
531                       @param   oldIndex  the byte positon of the old instance record
532                       @param   oldSize   the size of the old instance record
533                       @param   newIndex  the byte positon of the new instance record
534                       @param   newSize   the size of the new instance record
535               
536                       @return  true      if successful
537                                false     if an error occurs in modifying the instance
538                    */
539                   Boolean _modifyInstance(
540                       const String& path,
541                       const CIMInstance& object,
542                       Uint32 oldIndex,
543                       Uint32 oldSize,
544                       Uint32& newIndex,
545                       Uint32& newSize);
546               
547 mike  1.1.2.1     NameSpaceManager _nameSpaceManager;
548               
549                   // This must be initialized in the constructor using values from the
550                   // ConfigManager.
551                   Boolean _isDefaultInstanceProvider;
552               
553               protected:
554               
555                   ObjectStreamer *streamer;
556                   ReadWriteSem _lock;
557               
558                   friend class compilerDeclContext;
559                   friend class RepositoryDeclContext;
560                   DeclContext* _context;
561               
562                   /** Used by getInstance(); indicates whether instance should be resolved
563                       after it is retrieved from the file.
564                    */
565                   Boolean _resolveInstance;
566               
567                   CString _lockFile;
568 mike  1.1.2.1 };
569               
570               PEGASUS_NAMESPACE_END
571               
572               #endif /* Pegasus_DefaultRepository_h */

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2