(file) Return to MetaRepository.cpp 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               #include <cstdarg>
  35               #include <cassert>
  36               #include "MetaRepository.h"
  37               #include <Pegasus/Common/System.h>
  38               
  39 mike  1.1.2.2 #define TEST_META_REPOSITORY
  40               
  41               #if defined(TEST_META_REPOSITORY)
  42               # include "root_cimv2_namespace.h"
  43               # include "root_PG_Internal_namespace.h"
  44               # include "root_PG_InterOp_namespace.h"
  45 mike  1.1.2.1 #endif 
  46               
  47               PEGASUS_NAMESPACE_BEGIN
  48               
  49               static const size_t _MAX_NAMESPACES = 32;
  50               static const MetaNameSpace* _nameSpaces[_MAX_NAMESPACES];
  51               static size_t _nameSpacesSize = 0;
  52               
  53               static const size_t _MAX_FEATURES = 1024;
  54               static const size_t _MAX_QUALIFIERS = 1024;
  55               
  56 mike  1.1.2.2 #if defined(TEST_META_REPOSITORY)
  57 mike  1.1.2.1 static void _init()
  58               {
  59                   if (_nameSpacesSize == 0)
  60                   {
  61                       MetaRepository::addNameSpace(&root_PG_InterOp_namespace);
  62                       MetaRepository::addNameSpace(&root_cimv2_namespace);
  63                       MetaRepository::addNameSpace(&root_PG_Internal_namespace);
  64                   }
  65               }
  66               #endif
  67               
  68               static bool _eqi(const char* s1, const char* s2)
  69               {
  70                   return System::strcasecmp(s1, s2) == 0;
  71               }
  72               
  73               //==============================================================================
  74               //
  75               // Local definitions:
  76               //
  77               //==============================================================================
  78 mike  1.1.2.1 
  79               class Str
  80               {
  81               public:
  82                   Str(const String& s) : _cstr(s.getCString()) { }
  83                   Str(const CIMName& n) : _cstr(n.getString().getCString()) { }
  84                   Str(const CIMNamespaceName& n) : _cstr(n.getString().getCString()) { }
  85                   Str(const Exception& e) : _cstr(e.getMessage().getCString()) { }
  86                   Str(const CIMDateTime& x) : _cstr(x.toString().getCString()) { }
  87                   Str(const CIMObjectPath& x) : _cstr(x.toString().getCString()) { }
  88                   const char* operator*() const { return (const char*)_cstr; }
  89                   operator const char*() const { return (const char*)_cstr; }
  90               private:
  91                   CString _cstr;
  92               };
  93               
  94               PEGASUS_FORMAT(2, 3)
  95               static void _throw(CIMStatusCode code, const char* format, ...)
  96               {
  97                   char buffer[4096];
  98               
  99 mike  1.1.2.1     va_list ap;
 100                   va_start(ap, format);
 101                   vsprintf(buffer, format, ap);
 102                   va_end(ap);
 103                   throw CIMException(code, buffer);
 104               }
 105               
 106               static const MetaNameSpace* _findNameSpace(const char* name)
 107               {
 108                   for (size_t i = 0; i < _nameSpacesSize; i++)
 109                   {
 110                       if (_eqi(_nameSpaces[i]->name, name))
 111                           return _nameSpaces[i];
 112                   }
 113               
 114                   // Not found!
 115                   return 0;
 116               }
 117               
 118               static bool _isSubClass(const MetaClass* super, const MetaClass* sub)
 119               {
 120 mike  1.1.2.1     if (!super)
 121                       return true;
 122               
 123                   for (MetaClass* p = sub->super; p; p = p->super)
 124                   {
 125                       if (p == super)
 126                           return true;
 127                   }
 128               
 129                   return false;
 130               }
 131               
 132               static inline bool _isDirectSubClass(
 133                   const MetaClass* super, 
 134                   const MetaClass* sub)
 135               {
 136                   return sub->super == super;
 137               }
 138               
 139               static const MetaClass* _findClass(
 140                   const MetaNameSpace* ns, 
 141 mike  1.1.2.1     const char* name)
 142               {
 143                   for (size_t i = 0; ns->classes[i]; i++)
 144                   {
 145 mike  1.1.2.3         const MetaClass* mc = ns->classes[i];
 146 mike  1.1.2.1 
 147 mike  1.1.2.3         if (_eqi(mc->name, name))
 148                           return mc;
 149 mike  1.1.2.1     }
 150               
 151                   // Not found!
 152                   return 0;
 153               }
 154               
 155               static inline void _readBoolean(const char*& value, Boolean& x)
 156               {
 157                   unsigned const char* p = (unsigned const char*)value;
 158                   x = Boolean(p[0]);
 159                   value++;
 160               }
 161               
 162               static inline void _readUint8(const char*& value, Uint8& x)
 163               {
 164                   unsigned const char* p = (unsigned const char*)value;
 165                   x = Uint8(p[0]);
 166                   value += sizeof(x);
 167               }
 168               
 169               static inline void _readSint8(const char*& value, Sint8& x)
 170 mike  1.1.2.1 {
 171                   _readUint8(value, *((Uint8*)&x));
 172               }
 173               
 174               static inline void _readUint16(const char*& value, Uint16& x)
 175               {
 176                   unsigned const char* p = (unsigned const char*)value;
 177                   Uint16 x0 = Uint16(p[0]) << 8;
 178                   Uint16 x1 = Uint16(p[1]) << 0;
 179                   x = Uint16(x0 | x1);
 180                   value += sizeof(x);
 181               }
 182               
 183               static inline void _readSint16(const char*& value, Sint16& x)
 184               {
 185                   _readUint16(value, *((Uint16*)&x));
 186                   value += sizeof(x);
 187               }
 188               
 189               static inline void _readUint32(const char*& value, Uint32& x)
 190               {
 191 mike  1.1.2.1     unsigned const char* p = (unsigned const char*)value;
 192                   Uint32 x0 = Uint32(p[0]) << 24;
 193                   Uint32 x1 = Uint32(p[1]) << 16;
 194                   Uint32 x2 = Uint32(p[0]) <<  8;
 195                   Uint32 x3 = Uint32(p[1]) <<  0;
 196                   x = Uint32(x0 | x1 | x2 | x3);
 197                   value += sizeof(x);
 198               }
 199               
 200               static inline void _readSint32(const char*& value, Sint32& x)
 201               {
 202                   _readUint32(value, *((Uint32*)&x));
 203                   value += sizeof(x);
 204               }
 205               
 206               static inline void _readUint64(const char*& value, Uint64& x)
 207               {
 208                   unsigned const char* p = (unsigned const char*)value;
 209                   Uint64 x0 = Uint64(p[0]) << 56;
 210                   Uint64 x1 = Uint64(p[1]) << 48;
 211                   Uint64 x2 = Uint64(p[2]) << 40;
 212 mike  1.1.2.1     Uint64 x3 = Uint64(p[3]) << 32;
 213                   Uint64 x4 = Uint64(p[4]) << 24;
 214                   Uint64 x5 = Uint64(p[5]) << 16;
 215                   Uint64 x6 = Uint64(p[6]) <<  8;
 216                   Uint64 x7 = Uint64(p[7]) <<  0;
 217                   x = Uint64(x0 | x1 | x2 | x3 | x4 | x5 | x6 | x7);
 218                   value += sizeof(x);
 219               }
 220               
 221               static inline void _readSint64(const char*& value, Sint64& x)
 222               {
 223                   _readUint64(value, *((Uint64*)&x));
 224                   value += sizeof(x);
 225               }
 226               
 227               static inline void _readReal32(const char*& value, Real32& x)
 228               {
 229                   _readUint32(value, *((Uint32*)&x));
 230                   value += sizeof(x);
 231               }
 232               
 233 mike  1.1.2.1 static inline void _readReal64(const char*& value, Real64& x)
 234               {
 235                   _readUint64(value, *((Uint64*)&x));
 236                   value += sizeof(x);
 237               }
 238               
 239               static inline void _readChar16(const char*& value, Char16& x)
 240               {
 241                   _readUint16(value, *((Uint16*)&x));
 242                   value += sizeof(x);
 243               }
 244               
 245               static inline void _readString(const char*& value, String& x)
 246               {
 247                   size_t n = strlen(value);
 248                   x.assign(value, n);
 249                   value += n + 1;
 250               }
 251               
 252               static inline void _readDateTime(const char*& value, CIMDateTime& x)
 253               {
 254 mike  1.1.2.1     size_t n = strlen(value);
 255                   x.set(value);
 256                   value += n + 1;
 257               }
 258               
 259               static int _makeValue(
 260                   CIMValue& cv, 
 261                   Uint16 type, 
 262                   Sint16 subscript, 
 263                   const char* value)
 264               {
 265                   // If null value:
 266               
 267                   if (value == 0)
 268                   {
 269                       if (subscript == -1)
 270                           cv.setNullValue(CIMType(type), false);
 271                       else
 272                           cv.setNullValue(CIMType(type), true, subscript);
 273               
 274                       return 0;
 275 mike  1.1.2.1     }
 276               
 277                   // If scalar, else array:
 278               
 279                   if (subscript == -1)
 280                   {
 281                       switch (CIMType(type))
 282                       {
 283                           case CIMTYPE_BOOLEAN:
 284                           {
 285                               Boolean x;
 286                               _readBoolean(value, x);
 287                               cv.set(x);
 288                               return 0;
 289                           }
 290                           case CIMTYPE_UINT8:
 291                           {
 292                               Uint8 x;
 293                               _readUint8(value, x);
 294                               cv.set(x);
 295                               return 0;
 296 mike  1.1.2.1             }
 297                           case CIMTYPE_SINT8:
 298                           {
 299                               Sint8 x;
 300                               _readSint8(value, x);
 301                               cv.set(x);
 302                               return 0;
 303                           }
 304                           case CIMTYPE_UINT16:
 305                           {
 306                               Uint16 x;
 307                               _readUint16(value, x);
 308                               cv.set(x);
 309                               return 0;
 310                           }
 311                           case CIMTYPE_SINT16:
 312                           {
 313                               Sint16 x;
 314                               _readSint16(value, x);
 315                               cv.set(x);
 316                               return 0;
 317 mike  1.1.2.1             }
 318                           case CIMTYPE_UINT32:
 319                           {
 320                               Uint32 x;
 321                               _readUint32(value, x);
 322                               cv.set(x);
 323                               return 0;
 324                           }
 325                           case CIMTYPE_SINT32:
 326                           {
 327                               Sint32 x;
 328                               _readSint32(value, x);
 329                               cv.set(x);
 330                               return 0;
 331                           }
 332                           case CIMTYPE_UINT64:
 333                           {
 334                               Uint64 x;
 335                               _readUint64(value, x);
 336                               cv.set(x);
 337                               return 0;
 338 mike  1.1.2.1             }
 339                           case CIMTYPE_SINT64:
 340                           {
 341                               Sint64 x;
 342                               _readSint64(value, x);
 343                               cv.set(x);
 344                               return 0;
 345                           }
 346                           case CIMTYPE_REAL32:
 347                           {
 348                               Real32 x;
 349                               _readReal32(value, x);
 350                               cv.set(x);
 351                               return 0;
 352                           }
 353                           case CIMTYPE_REAL64:
 354                           {
 355                               Real64 x;
 356                               _readReal64(value, x);
 357                               cv.set(x);
 358                               return 0;
 359 mike  1.1.2.1             }
 360                           case CIMTYPE_CHAR16:
 361                           {
 362                               Char16 x;
 363                               _readChar16(value, x);
 364                               cv.set(x);
 365                               return 0;
 366                           }
 367                           case CIMTYPE_STRING:
 368                           {
 369                               String x;
 370                               _readString(value, x);
 371                               cv.set(x);
 372                               return 0;
 373                           }
 374                           case CIMTYPE_DATETIME:
 375                           {
 376                               CIMDateTime x;
 377                               _readDateTime(value, x);
 378                               cv.set(x);
 379                               return 0;
 380 mike  1.1.2.1             }
 381               
 382                           default:
 383                               printf("T[%u]\n", __LINE__);
 384                               return -1;
 385                       }
 386                   }
 387                   else
 388                   {
 389                       // Read array size:
 390               
 391                       Uint16 size;
 392                       _readUint16(value, size);
 393               
 394                       // Read array elements:
 395               
 396                       switch (CIMType(type))
 397                       {
 398                           case CIMTYPE_BOOLEAN:
 399                           {
 400                               Array<Boolean> a;
 401 mike  1.1.2.1 
 402                               for (Uint16 i = 0; i < size; i++)
 403                               {
 404                                   Boolean x;
 405                                   _readBoolean(value, x);
 406                                   a.append(x);
 407                               }
 408               
 409                               cv.set(a);
 410                               return 0;
 411                           }
 412                           case CIMTYPE_UINT8:
 413                           {
 414                               Array<Uint8> a;
 415               
 416                               for (Uint16 i = 0; i < size; i++)
 417                               {
 418                                   Uint8 x;
 419                                   _readUint8(value, x);
 420                                   a.append(x);
 421                               }
 422 mike  1.1.2.1 
 423                               cv.set(a);
 424                               return 0;
 425                           }
 426                           case CIMTYPE_SINT8:
 427                           {
 428                               Array<Sint8> a;
 429               
 430                               for (Uint16 i = 0; i < size; i++)
 431                               {
 432                                   Sint8 x;
 433                                   _readSint8(value, x);
 434                                   a.append(x);
 435                               }
 436               
 437                               cv.set(a);
 438                               return 0;
 439                           }
 440                           case CIMTYPE_UINT16:
 441                           {
 442                               Array<Uint16> a;
 443 mike  1.1.2.1 
 444                               for (Uint16 i = 0; i < size; i++)
 445                               {
 446                                   Uint16 x;
 447                                   _readUint16(value, x);
 448                                   a.append(x);
 449                               }
 450               
 451                               cv.set(a);
 452                               return 0;
 453                           }
 454                           case CIMTYPE_SINT16:
 455                           {
 456                               Array<Sint16> a;
 457               
 458                               for (Uint16 i = 0; i < size; i++)
 459                               {
 460                                   Sint16 x;
 461                                   _readSint16(value, x);
 462                                   a.append(x);
 463                               }
 464 mike  1.1.2.1 
 465                               cv.set(a);
 466                               return 0;
 467                           }
 468                           case CIMTYPE_UINT32:
 469                           {
 470                               Array<Uint32> a;
 471               
 472                               for (Uint16 i = 0; i < size; i++)
 473                               {
 474                                   Uint32 x;
 475                                   _readUint32(value, x);
 476                                   a.append(x);
 477                               }
 478               
 479                               cv.set(a);
 480                               return 0;
 481                           }
 482                           case CIMTYPE_SINT32:
 483                           {
 484                               Array<Sint32> a;
 485 mike  1.1.2.1 
 486                               for (Uint16 i = 0; i < size; i++)
 487                               {
 488                                   Sint32 x;
 489                                   _readSint32(value, x);
 490                                   a.append(x);
 491                               }
 492               
 493                               cv.set(a);
 494                               return 0;
 495                           }
 496                           case CIMTYPE_UINT64:
 497                           {
 498                               Array<Uint64> a;
 499               
 500                               for (Uint16 i = 0; i < size; i++)
 501                               {
 502                                   Uint64 x;
 503                                   _readUint64(value, x);
 504                                   a.append(x);
 505                               }
 506 mike  1.1.2.1 
 507                               cv.set(a);
 508                               return 0;
 509                           }
 510                           case CIMTYPE_SINT64:
 511                           {
 512                               Array<Sint64> a;
 513               
 514                               for (Uint16 i = 0; i < size; i++)
 515                               {
 516                                   Sint64 x;
 517                                   _readSint64(value, x);
 518                                   a.append(x);
 519                               }
 520               
 521                               cv.set(a);
 522                               return 0;
 523                           }
 524                           case CIMTYPE_REAL32:
 525                           {
 526                               Array<Real32> a;
 527 mike  1.1.2.1 
 528                               for (Uint16 i = 0; i < size; i++)
 529                               {
 530                                   Real32 x;
 531                                   _readReal32(value, x);
 532                                   a.append(x);
 533                               }
 534               
 535                               cv.set(a);
 536                               return 0;
 537                           }
 538                           case CIMTYPE_REAL64:
 539                           {
 540                               Array<Real64> a;
 541               
 542                               for (Uint16 i = 0; i < size; i++)
 543                               {
 544                                   Real64 x;
 545                                   _readReal64(value, x);
 546                                   a.append(x);
 547                               }
 548 mike  1.1.2.1 
 549                               cv.set(a);
 550                               return 0;
 551                           }
 552                           case CIMTYPE_CHAR16:
 553                           {
 554                               Array<Char16> a;
 555               
 556                               for (Uint16 i = 0; i < size; i++)
 557                               {
 558                                   Char16 x;
 559                                   _readChar16(value, x);
 560                                   a.append(x);
 561                               }
 562               
 563                               cv.set(a);
 564                               return 0;
 565                           }
 566                           case CIMTYPE_STRING:
 567                           {
 568                               Array<String> a;
 569 mike  1.1.2.1 
 570                               for (Uint16 i = 0; i < size; i++)
 571                               {
 572                                   String x;
 573                                   _readString(value, x);
 574                                   a.append(x);
 575                               }
 576               
 577                               cv.set(a);
 578                               return 0;
 579                           }
 580                           case CIMTYPE_DATETIME:
 581                           {
 582                               Array<CIMDateTime> a;
 583               
 584                               for (Uint16 i = 0; i < size; i++)
 585                               {
 586                                   CIMDateTime x;
 587                                   _readDateTime(value, x);
 588                                   a.append(x);
 589                               }
 590 mike  1.1.2.1 
 591                               cv.set(a);
 592                               return 0;
 593                           }
 594               
 595                           default:
 596                               printf("T[%u]\n", __LINE__);
 597                               return -1;
 598                       }
 599                   }
 600               
 601                   // Unreachable!
 602                   printf("T[%u]\n", __LINE__);
 603                   return -1;
 604               }
 605               
 606               struct FeatureInfo
 607               {
 608 mike  1.1.2.3     const MetaFeature* mf;
 609                   const MetaClass* mc;
 610 mike  1.1.2.1 };
 611               
 612               static int _mergeFeatures(
 613 mike  1.1.2.3     const MetaClass* mc,
 614                   bool localOnly,
 615 mike  1.1.2.1     FeatureInfo features[_MAX_FEATURES],
 616                   size_t& numFeatures)
 617               {
 618 mike  1.1.2.3     if (!localOnly && mc->super)
 619 mike  1.1.2.1     {
 620 mike  1.1.2.3         if (_mergeFeatures(mc->super, localOnly, features, numFeatures) != 0)
 621 mike  1.1.2.1         {
 622                           printf("T[%u]\n", __LINE__);
 623                           return -1;
 624                       }
 625                   }
 626               
 627                   // Process all features of this class:
 628               
 629 mike  1.1.2.3     for (size_t i = 0; mc->features[i]; i++)
 630 mike  1.1.2.1     {
 631 mike  1.1.2.3         const MetaFeature* mf = mc->features[i];
 632 mike  1.1.2.1 
 633                       // Override feature if defined by ancestor class:
 634               
 635                       bool found = false;
 636               
 637                       for (size_t j = 0; j < numFeatures; j++)
 638                       {
 639 mike  1.1.2.3             const MetaFeature* tmp = features[j].mf;
 640 mike  1.1.2.1 
 641 mike  1.1.2.3             if (_eqi(mf->name, tmp->name))
 642 mike  1.1.2.1             {
 643 mike  1.1.2.3                 features[j].mf = mf;
 644                               features[j].mc = mc;
 645 mike  1.1.2.1                 found = true;
 646                               break;
 647                           }
 648                       }
 649               
 650                       // Add new feature if not not defined by ancestor class:
 651               
 652                       if (!found)
 653                       {
 654                           if (numFeatures == _MAX_FEATURES)
 655                           {
 656                               printf("T[%u]\n", __LINE__);
 657                               return -1;
 658                           }
 659               
 660 mike  1.1.2.3             features[numFeatures].mf = mf;
 661                           features[numFeatures].mc = mc;
 662 mike  1.1.2.1             numFeatures++;
 663                       }
 664                   }
 665               
 666                   return 0;
 667               }
 668               
 669               struct QualifierInfo
 670               {
 671                   const char* qualifier;
 672 mike  1.1.2.3     const MetaClass* mc;
 673 mike  1.1.2.1 };
 674               
 675               static const MetaFeature* _findFeature(
 676 mike  1.1.2.3     const MetaClass* mc, 
 677 mike  1.1.2.1     const char* name)
 678               {
 679 mike  1.1.2.3     for (size_t i = 0; mc->features[i]; i++)
 680 mike  1.1.2.1     {
 681 mike  1.1.2.3         const MetaFeature* mf = mc->features[i];
 682 mike  1.1.2.1 
 683 mike  1.1.2.3         if (_eqi(mf->name, name))
 684                           return mf;
 685 mike  1.1.2.1     }
 686               
 687                   // Not found!
 688                   return 0;
 689               }
 690               
 691               static const MetaFeature* _findParameter(
 692 mike  1.1.2.3     const MetaMethod* mm, 
 693 mike  1.1.2.1     const char* name)
 694               {
 695 mike  1.1.2.3     for (size_t i = 0; mm->parameters[i]; i++)
 696 mike  1.1.2.1     {
 697 mike  1.1.2.3         const MetaFeature* mf = mm->parameters[i];
 698 mike  1.1.2.1 
 699 mike  1.1.2.3         if (_eqi(mm->name, name))
 700                           return mf;
 701 mike  1.1.2.1     }
 702               
 703                   // Not found!
 704                   return 0;
 705               }
 706               
 707               static int _mergeQualifiers(
 708                   const MetaNameSpace* ns,
 709 mike  1.1.2.3     const MetaClass* mc,
 710 mike  1.1.2.1     const char* featureName,
 711                   const char* parameterName,
 712                   bool depth,
 713                   QualifierInfo qualifiers[_MAX_QUALIFIERS],
 714                   size_t& numQualifiers)
 715               {
 716                   // Merge super-class qualifiers:
 717               
 718 mike  1.1.2.3     if (mc->super)
 719 mike  1.1.2.1     {
 720 mike  1.1.2.3         _mergeQualifiers(ns, mc->super, featureName, parameterName, depth + 1,
 721 mike  1.1.2.1             qualifiers, numQualifiers);
 722                   }
 723               
 724                   const char** quals = 0;
 725               
 726                   // Find qualifiers of the given object:
 727               
 728                   if (!featureName && !parameterName)
 729                   {
 730                       // Case 1: get class qualifiers:
 731 mike  1.1.2.3         quals = mc->qualifiers;
 732 mike  1.1.2.1     }
 733                   else if (featureName && !parameterName)
 734                   {
 735                       // Case 2: get feature qualifiers:
 736               
 737 mike  1.1.2.3         const MetaFeature* mf = _findFeature(mc, featureName);
 738 mike  1.1.2.1 
 739 mike  1.1.2.3         if (mf)
 740                           quals = mf->qualifiers;
 741 mike  1.1.2.1     }
 742                   else if (featureName && parameterName)
 743                   {
 744                       // Case 3: get parameter qualifiers:
 745               
 746 mike  1.1.2.3         const MetaFeature* mf = _findFeature(mc, featureName);
 747 mike  1.1.2.1 
 748 mike  1.1.2.3         if (mf && (mf->flags & META_FLAG_METHOD))
 749 mike  1.1.2.1         {
 750 mike  1.1.2.3             const MetaMethod* mm = (const MetaMethod*)mf;
 751                           const MetaFeature* p = _findParameter(mm, parameterName);
 752 mike  1.1.2.1 
 753                           if (p)
 754                               quals = p->qualifiers;
 755                       }
 756                   }
 757               
 758                   // Merge quals into the qualifiers array:
 759               
 760                   if (!quals)
 761                       return 0;
 762               
 763                   for (size_t i = 0; quals[i]; i++)
 764                   {
 765                       const char* qi = quals[i];
 766               
 767                       // Override existing qualifier if any:
 768               
 769                       bool found = false;
 770               
 771                       for (size_t j = 0; j < numQualifiers; j++)
 772                       {
 773 mike  1.1.2.1             const char* qj = qualifiers[j].qualifier;
 774               
 775                           if (qi[0] == qj[0])
 776                           {
 777                               qualifiers[j].qualifier = qi;
 778 mike  1.1.2.3                 qualifiers[j].mc = mc;
 779 mike  1.1.2.1                 found = true;
 780                               break;
 781                           }
 782                       }
 783               
 784                       // Inject this qualifier not found:
 785               
 786                       if (!found)
 787                       {
 788                           MetaQualifierDecl* qd = ns->qualifiers[qi[0]];
 789               
 790                           if (depth == 0 || !(qd->flavor & META_FLAVOR_RESTRICTED))
 791                           {
 792                               if (numQualifiers == _MAX_QUALIFIERS)
 793                               {
 794                                   printf("T[%u]\n", __LINE__);
 795                                   return -1;
 796                               }
 797               
 798                               qualifiers[numQualifiers].qualifier = qi;
 799 mike  1.1.2.3                 qualifiers[numQualifiers].mc = mc;
 800 mike  1.1.2.1                 numQualifiers++;
 801                           }
 802                       }
 803                   }
 804               
 805                   return 0;
 806               }
 807               
 808               template<class C>
 809               static int _addQualifiers(
 810                   const MetaNameSpace* ns,
 811 mike  1.1.2.3     const MetaClass* mc,
 812 mike  1.1.2.1     const char* featureName,
 813                   const char* parameterName,
 814                   C& c)
 815               {
 816                   QualifierInfo qualifiers[_MAX_QUALIFIERS];
 817                   size_t numQualifiers = 0;
 818               
 819                   if (_mergeQualifiers(
 820 mike  1.1.2.3         ns, mc, featureName, parameterName, 0, qualifiers, numQualifiers) != 0)
 821 mike  1.1.2.1     {
 822                       printf("T[%u]\n", __LINE__);
 823                       return -1;
 824                   }
 825               
 826                   // Add qualifiers to container:
 827               
 828                   for (size_t i = 0; i < numQualifiers; i++)
 829                   {
 830                       const char* q = qualifiers[i].qualifier;
 831               
 832                       // Get qualifier id:
 833               
 834                       Uint8 qid = Uint8(q[0]);
 835               
 836                       // Get qualifier declaration:
 837               
 838                       MetaQualifierDecl* qd = ns->qualifiers[qid];
 839               
 840                       // Make CIMValue:
 841               
 842 mike  1.1.2.1         CIMValue cv;
 843               
 844                       if (_makeValue(cv, qd->type, qd->subscript, q + 1) != 0)
 845                       {
 846                           printf("T[%u]\n", __LINE__);
 847                           return -1;
 848                       }
 849               
 850                       // Add qualifier:
 851               
 852                       c.addQualifier(CIMQualifier(qd->name, cv));
 853                   }
 854               
 855                   return 0;
 856               }
 857               
 858               static int _addProperty(
 859                   const MetaNameSpace* ns,
 860 mike  1.1.2.3     const MetaClass* mc,
 861                   const MetaProperty* mp,
 862 mike  1.1.2.1     const char* classOrigin,
 863                   bool propagated,
 864 mike  1.1.2.3     bool includeQualifiers,
 865                   bool includeClassOrigin,
 866 mike  1.1.2.1     CIMClass& cc)
 867               {
 868                   // Make CIMvalue:
 869               
 870                   CIMValue cv;
 871               
 872 mike  1.1.2.3     if (_makeValue(cv, mp->type, mp->subscript, mp->value) != 0)
 873 mike  1.1.2.1     {
 874                       printf("T[%u]\n", __LINE__);
 875                       return -1;
 876                   }
 877               
 878                   // Create property:
 879               
 880 mike  1.1.2.3     CIMProperty cp(mp->name, cv);
 881               
 882                   if (includeClassOrigin)
 883                       cp.setClassOrigin(classOrigin);
 884               
 885 mike  1.1.2.1     cp.setPropagated(propagated);
 886               
 887                   // Add qualifiers:
 888               
 889 mike  1.1.2.3     if (includeQualifiers)
 890 mike  1.1.2.1     {
 891 mike  1.1.2.3         if (_addQualifiers(ns, mc, mp->name, 0, cp) != 0)
 892                       {
 893                           printf("T[%u]\n", __LINE__);
 894                           return -1;
 895                       }
 896 mike  1.1.2.1     }
 897               
 898                   // Add to class:
 899               
 900                   cc.addProperty(cp);
 901                   return 0;
 902               }
 903               
 904               static int _addReference(
 905                   const MetaNameSpace* ns,
 906 mike  1.1.2.3     const MetaClass* mc,
 907                   const MetaReference* mr,
 908 mike  1.1.2.1     const char* classOrigin,
 909                   bool propagated,
 910 mike  1.1.2.3     bool includeQualifiers,
 911                   bool includeClassOrigin,
 912 mike  1.1.2.1     CIMClass& cc)
 913               {
 914                   // Set isArray and arraySize:
 915               
 916                   Boolean isArray;
 917                   Uint32 arraySize;
 918                   
 919 mike  1.1.2.3     if (mr->subscript == -1)
 920 mike  1.1.2.1     {
 921                       isArray = false;
 922                       arraySize = 0;
 923                   }
 924                   else
 925                   {
 926                       isArray = true;
 927 mike  1.1.2.3         arraySize = mr->subscript;
 928 mike  1.1.2.1     }
 929               
 930                   // Set referenceClassName:
 931               
 932 mike  1.1.2.3     CIMName rcn = mr->ref->name;
 933 mike  1.1.2.1 
 934                   // Create value:
 935               
 936                   CIMValue cv(CIMTYPE_REFERENCE, isArray, arraySize);
 937               
 938                   // Create property:
 939               
 940 mike  1.1.2.3     CIMProperty cp(mr->name, cv, arraySize, rcn);
 941               
 942                   if (includeClassOrigin)
 943                       cp.setClassOrigin(classOrigin);
 944               
 945                   cp.setPropagated(propagated);
 946 mike  1.1.2.1 
 947                   // Add qualifiers:
 948               
 949 mike  1.1.2.3     if (includeQualifiers)
 950 mike  1.1.2.1     {
 951 mike  1.1.2.3         if (_addQualifiers(ns, mc, mr->name, 0, cp) != 0)
 952                       {
 953                           printf("T[%u]\n", __LINE__);
 954                           return -1;
 955                       }
 956 mike  1.1.2.1     }
 957               
 958                   // Add to class:
 959               
 960                   cc.addProperty(cp);
 961                   return 0;
 962               }
 963               
 964               static int _addPropertyParameter(
 965                   const MetaNameSpace* ns,
 966 mike  1.1.2.3     const MetaClass* mc,
 967                   const MetaMethod* mm,
 968                   const MetaProperty* mp,
 969                   bool includeQualifiers,
 970 mike  1.1.2.1     CIMMethod& cm)
 971               {
 972                   // Create property:
 973               
 974                   bool isArray;
 975                   Uint32 arraySize;
 976               
 977 mike  1.1.2.3     if (mp->subscript == -1)
 978 mike  1.1.2.1     {
 979                       isArray = false;
 980                       arraySize = 0;
 981                   }
 982                   else 
 983                   {
 984                       isArray = true;
 985 mike  1.1.2.3         arraySize = Uint32(mp->subscript);
 986 mike  1.1.2.1     }
 987               
 988 mike  1.1.2.3     CIMParameter cp(mp->name, CIMType(mp->type), isArray, arraySize);
 989 mike  1.1.2.1 
 990                   // Add qualifiers:
 991               
 992 mike  1.1.2.3     if (includeQualifiers)
 993 mike  1.1.2.1     {
 994 mike  1.1.2.3         if (_addQualifiers(ns, mc, mm->name, mp->name, cm) != 0)
 995                       {
 996                           printf("T[%u]\n", __LINE__);
 997                           return -1;
 998                       }
 999 mike  1.1.2.1     }
1000               
1001                   // Add to method:
1002               
1003                   cm.addParameter(cp);
1004                   return 0;
1005               }
1006               
1007               static int _addReferenceParameter(
1008                   const MetaNameSpace* ns,
1009 mike  1.1.2.3     const MetaClass* mc,
1010                   const MetaMethod* mm,
1011                   const MetaReference* mr,
1012                   bool includeQualifiers,
1013 mike  1.1.2.1     CIMMethod& cm)
1014               {
1015                   // Create property:
1016               
1017                   bool isArray;
1018                   Uint32 arraySize;
1019               
1020 mike  1.1.2.3     if (mr->subscript == -1)
1021 mike  1.1.2.1     {
1022                       isArray = false;
1023                       arraySize = 0;
1024                   }
1025                   else 
1026                   {
1027                       isArray = true;
1028 mike  1.1.2.3         arraySize = Uint32(mr->subscript);
1029 mike  1.1.2.1     }
1030               
1031 mike  1.1.2.3     CIMName rcn = mr->ref->name;
1032                   CIMParameter cp(mr->name, CIMTYPE_REFERENCE, isArray, arraySize, rcn);
1033 mike  1.1.2.1 
1034                   // Add qualifiers:
1035               
1036 mike  1.1.2.3     if (includeQualifiers)
1037 mike  1.1.2.1     {
1038 mike  1.1.2.3         if (_addQualifiers(ns, mc, mm->name, mr->name, cm) != 0)
1039                       {
1040                           printf("T[%u]\n", __LINE__);
1041                           return -1;
1042                       }
1043 mike  1.1.2.1     }
1044               
1045                   // Add to method:
1046               
1047                   cm.addParameter(cp);
1048                   return 0;
1049               }
1050               
1051               static int _addMethod(
1052                   const MetaNameSpace* ns,
1053 mike  1.1.2.3     const MetaClass* mc,
1054                   const MetaMethod* mm,
1055 mike  1.1.2.1     const char* classOrigin,
1056                   bool propagated,
1057 mike  1.1.2.3     bool includeQualifiers,
1058                   bool includeClassOrigin,
1059 mike  1.1.2.1     CIMClass& cc)
1060               {
1061                   // Create method:
1062               
1063 mike  1.1.2.3     CIMMethod cm(mm->name, CIMType(mm->type));
1064               
1065                   if (includeClassOrigin)
1066                       cm.setClassOrigin(classOrigin);
1067               
1068 mike  1.1.2.1     cm.setPropagated(propagated);
1069               
1070                   // Add parameters:
1071               
1072 mike  1.1.2.3     for (size_t i = 0; mm->parameters[i]; i++)
1073 mike  1.1.2.1     {
1074 mike  1.1.2.3         MetaFeature* mf = mm->parameters[i];
1075 mike  1.1.2.1 
1076 mike  1.1.2.3         if (mf->flags & META_FLAG_PROPERTY)
1077 mike  1.1.2.1         {
1078 mike  1.1.2.3             MetaProperty* mp = (MetaProperty*)mf;
1079                           _addPropertyParameter(ns, mc, mm, mp, includeQualifiers, cm);
1080 mike  1.1.2.1         }
1081 mike  1.1.2.3         else if (mf->flags & META_FLAG_REFERENCE)
1082 mike  1.1.2.1         {
1083 mike  1.1.2.3             MetaReference* mr = (MetaReference*)mf;
1084                           _addReferenceParameter(ns, mc, mm, mr, includeQualifiers, cm);
1085 mike  1.1.2.1         }
1086                   }
1087               
1088                   // Add qualifiers:
1089               
1090 mike  1.1.2.3     if (includeQualifiers)
1091 mike  1.1.2.1     {
1092 mike  1.1.2.3         if (_addQualifiers(ns, mc, mm->name, 0, cm) != 0)
1093                       {
1094                           printf("T[%u]\n", __LINE__);
1095                           return -1;
1096                       }
1097 mike  1.1.2.1     }
1098               
1099                   // Add to class:
1100               
1101                   cc.addMethod(cm);
1102                   return 0;
1103               }
1104               
1105 mike  1.1.2.3 static bool _hasProperty(const char* const* propertyList, const char* name)
1106               {
1107                   for (size_t i = 0; propertyList[i]; i++)
1108                   {
1109                       if (_eqi(propertyList[i], name))
1110                           return true;
1111                   }
1112               
1113                   return false;
1114               }
1115               
1116 mike  1.1.2.1 static int _addFeatures(
1117                   const MetaNameSpace* ns,
1118 mike  1.1.2.3     const MetaClass* mc,
1119                   bool localOnly,
1120                   bool includeQualifiers,
1121                   bool includeClassOrigin,
1122                   const char* const* propertyList,
1123 mike  1.1.2.1     CIMClass& cc)
1124               {
1125                   // Merge features from all inheritance levels into a single array:
1126               
1127                   FeatureInfo features[_MAX_FEATURES];
1128                   size_t numFeatures = 0;
1129               
1130 mike  1.1.2.3     if (_mergeFeatures(mc, localOnly, features, numFeatures) != 0)
1131 mike  1.1.2.1     {
1132                       printf("T[%u]\n", __LINE__);
1133                       return -1;
1134                   }
1135               
1136                   // For each feature:
1137               
1138                   for (size_t i = 0; i < numFeatures; i++)
1139                   {
1140                       const FeatureInfo& fi = features[i];
1141               
1142                       // Set propagated flag:
1143               
1144 mike  1.1.2.3         bool propagated = fi.mc != mc;
1145 mike  1.1.2.1 
1146                       // Set classOrigin:
1147               
1148 mike  1.1.2.3         const char* classOrigin = fi.mc->name;
1149 mike  1.1.2.1 
1150 mike  1.1.2.3         // Skip feature not in property list:
1151 mike  1.1.2.1 
1152 mike  1.1.2.3         const MetaFeature* mf = fi.mf;
1153 mike  1.1.2.1 
1154 mike  1.1.2.3         if (propertyList && !_hasProperty(propertyList, mf->name))
1155                           continue;
1156               
1157                       // Add the feature:
1158               
1159                       if (mf->flags & META_FLAG_PROPERTY)
1160 mike  1.1.2.1         {
1161 mike  1.1.2.3             MetaProperty* mp = (MetaProperty*)mf;
1162 mike  1.1.2.1 
1163 mike  1.1.2.3             if (_addProperty(ns, mc, mp, classOrigin, propagated, 
1164                               includeQualifiers, includeClassOrigin, cc) != 0)
1165 mike  1.1.2.1             {
1166                               printf("T[%u]\n", __LINE__);
1167                               return -1;
1168                           }
1169                       }
1170 mike  1.1.2.3         else if (mf->flags & META_FLAG_REFERENCE)
1171 mike  1.1.2.1         {
1172 mike  1.1.2.3             MetaReference* mr = (MetaReference*)mf;
1173 mike  1.1.2.1 
1174 mike  1.1.2.3             if (_addReference(ns, mc, mr, classOrigin, propagated, 
1175                               includeQualifiers, includeClassOrigin, cc) != 0)
1176 mike  1.1.2.1             {
1177                               printf("T[%u]\n", __LINE__);
1178                               return -1;
1179                           }
1180                       }
1181 mike  1.1.2.3         else if (mf->flags & META_FLAG_METHOD)
1182 mike  1.1.2.1         {
1183 mike  1.1.2.3             MetaMethod* mm = (MetaMethod*)mf;
1184 mike  1.1.2.1 
1185 mike  1.1.2.3             if (_addMethod(ns, mc, mm, classOrigin, propagated, 
1186                               includeQualifiers, includeClassOrigin, cc) != 0)
1187 mike  1.1.2.1             {
1188                               printf("T[%u]\n", __LINE__);
1189                               return -1;
1190                           }
1191                       }
1192                   }
1193               
1194                   return 0;
1195               }
1196               
1197               static int _makeClass(
1198                   const MetaNameSpace* ns,
1199 mike  1.1.2.3     const MetaClass* mc,
1200                   Boolean localOnly,
1201                   Boolean includeQualifiers,
1202                   Boolean includeClassOrigin,
1203                   const char* const* propertyList,
1204                   CIMClass& cc)
1205 mike  1.1.2.1 {
1206                   try
1207                   {
1208                       // Create class:
1209                       {
1210                           CIMName scn;
1211               
1212 mike  1.1.2.3             if (mc->super)
1213                               scn = mc->super->name;
1214 mike  1.1.2.1 
1215 mike  1.1.2.3             cc = CIMClass(mc->name, scn);
1216                       }
1217 mike  1.1.2.1 
1218                       // Add qualifiers:
1219               
1220 mike  1.1.2.3         if (includeQualifiers)
1221 mike  1.1.2.1         {
1222 mike  1.1.2.3             if (_addQualifiers(ns, mc, 0, 0, cc) != 0)
1223                           {
1224                               printf("T[%u]\n", __LINE__);
1225                               return -1;
1226                           }
1227 mike  1.1.2.1         }
1228               
1229                       // Features:
1230               
1231 mike  1.1.2.3         if (_addFeatures(ns, mc, localOnly, includeQualifiers, 
1232                           includeClassOrigin, propertyList, cc) != 0)
1233 mike  1.1.2.1         {
1234                           printf("T[%u]\n", __LINE__);
1235                           return -1;
1236                       }
1237                   }
1238                   catch (Exception& e)
1239                   {
1240                       printf("EXCEPTION[%s]\n", *Str(e));
1241                       return -1;
1242                   }
1243                   catch (...)
1244                   {
1245                       printf("T[%u]\n", __LINE__);
1246                       return -1;
1247                   }
1248               
1249                   return 0;
1250               }
1251               
1252 mike  1.1.2.3 static char** _makePropertyList(const CIMPropertyList& propertyList)
1253               {
1254                   if (propertyList.isNull())
1255                       return 0;
1256               
1257                   size_t size = propertyList.size();
1258                   char** pl = (char**)malloc(sizeof(char*) * (size + 1));
1259               
1260                   for (size_t i = 0; i < size; i++)
1261                       pl[i] = strdup(*Str(propertyList[i]));
1262               
1263                   pl[size] = 0;
1264               
1265                   return pl;
1266               }
1267               
1268               static void _freePropertyList(char** pl)
1269               {
1270                   if (!pl)
1271                       return;
1272               
1273 mike  1.1.2.3     for (size_t i = 0; pl[i]; i++)
1274                   {
1275                       free(pl[i]);
1276                   }
1277               
1278                   free(pl);
1279               }
1280               
1281               static void _printPropertyList(const char* const* pl)
1282               {
1283                   if (!pl)
1284                       return;
1285               
1286                   for (size_t i = 0; pl[i]; i++)
1287                       printf("pl[%s]\n", pl[i]);
1288               }
1289               
1290 mike  1.1.2.1 //==============================================================================
1291               //
1292               // class MetaRepository
1293               //
1294               //==============================================================================
1295               
1296               MetaRepository::MetaRepository()
1297               {
1298               }
1299               
1300               MetaRepository::~MetaRepository()
1301               {
1302               }
1303               
1304               bool MetaRepository::addNameSpace(const MetaNameSpace* nameSpace)
1305               {
1306                   if (_nameSpacesSize == _MAX_NAMESPACES || !nameSpace)
1307                       return false;
1308               
1309                   for (size_t i = 0; i < _nameSpacesSize; i++)
1310                   {
1311 mike  1.1.2.1         if (_eqi(_nameSpaces[i]->name, nameSpace->name))
1312                           return false;
1313                   }
1314               
1315                   _nameSpaces[_nameSpacesSize++] = nameSpace;
1316                   return true;
1317               }
1318               
1319               CIMClass MetaRepository::getClass(
1320                   const CIMNamespaceName& nameSpace,
1321                   const CIMName& className,
1322                   Boolean localOnly,
1323                   Boolean includeQualifiers,
1324                   Boolean includeClassOrigin,
1325                   const CIMPropertyList& propertyList)
1326               {
1327 mike  1.1.2.3     printf("===== MetaRepository::getClass()\n");
1328               
1329                   // ATTN-MEB: propertyList ignored!
1330               
1331               #if defined(TEST_META_REPOSITORY)
1332                   _init();
1333               #endif
1334               
1335                   // Lookup namespace:
1336               
1337                   const MetaNameSpace* ns = _findNameSpace(*Str(nameSpace));
1338               
1339                   if (!ns)
1340                       _throw(CIM_ERR_INVALID_NAMESPACE, "%s", *Str(nameSpace));
1341               
1342                   // Lookup class:
1343               
1344                   const MetaClass* mc = _findClass(ns, *Str(className));
1345               
1346                   if (!mc)
1347                       _throw(CIM_ERR_NOT_FOUND, "unknown class: %s", *Str(className));
1348 mike  1.1.2.3 
1349                   // Build property list:
1350               
1351                   char** pl = _makePropertyList(propertyList);
1352               
1353                   // Make class:
1354               
1355                   CIMClass cc;
1356               
1357                   if (_makeClass(ns, mc, localOnly, includeQualifiers, 
1358                       includeQualifiers, pl, cc) != 0)
1359                   {
1360                       _freePropertyList(pl);
1361                       _throw(CIM_ERR_FAILED, "conversion failed: %s", mc->name);
1362                   }
1363               
1364                   _freePropertyList(pl);
1365                   return cc;
1366 mike  1.1.2.1 }
1367               
1368               Array<CIMClass> MetaRepository::enumerateClasses(
1369                   const CIMNamespaceName& nameSpace,
1370                   const CIMName& className,
1371                   Boolean deepInheritance,
1372                   Boolean localOnly,
1373                   Boolean includeQualifiers,
1374                   Boolean includeClassOrigin)
1375               {
1376 mike  1.1.2.3     printf("===== MetaRepository::enumerateClasses()\n");
1377               
1378 mike  1.1.2.2 #if defined(TEST_META_REPOSITORY)
1379 mike  1.1.2.1     _init();
1380               #endif
1381               
1382                   // Lookup namespace:
1383               
1384                   const MetaNameSpace* ns = _findNameSpace(*Str(nameSpace));
1385               
1386                   if (!ns)
1387                       _throw(CIM_ERR_INVALID_NAMESPACE, "%s", *Str(nameSpace));
1388               
1389                   // Lookup class:
1390               
1391                   const MetaClass* super = 0;
1392                   
1393                   if (!className.isNull())
1394                   {
1395                       super = _findClass(ns, *Str(className));
1396               
1397                       if (!super)
1398                           _throw(CIM_ERR_NOT_FOUND, "unknown class: %s", *Str(className));
1399                   }
1400 mike  1.1.2.1 
1401                   // Iterate all classes looking for matches:
1402               
1403                   Array<CIMClass> result;
1404               
1405                   for (size_t i = 0; ns->classes[i]; i++)
1406                   {
1407 mike  1.1.2.3         MetaClass* mc = ns->classes[i];
1408 mike  1.1.2.1 
1409 mike  1.1.2.3         bool flag = false;
1410 mike  1.1.2.1 
1411                       if (deepInheritance)
1412                       {
1413 mike  1.1.2.3             if (_isSubClass(super, mc))
1414                               flag = true;
1415 mike  1.1.2.1         }
1416                       else
1417                       {
1418 mike  1.1.2.3             if (_isDirectSubClass(super, mc))
1419                               flag = true;
1420                       }
1421               
1422                       if (flag)
1423                       {
1424                           CIMClass cc;
1425 mike  1.1.2.1 
1426 mike  1.1.2.3             if (_makeClass(ns, mc, localOnly, includeQualifiers, 
1427                               includeQualifiers, 0, cc) != 0)
1428                           {
1429                               _throw(CIM_ERR_FAILED, "conversion failed: %s", mc->name);
1430 mike  1.1.2.1             }
1431 mike  1.1.2.3             else
1432                               result.append(cc);
1433 mike  1.1.2.1         }
1434                   }
1435               
1436                   return result;
1437               }
1438               
1439               Array<CIMName> MetaRepository::enumerateClassNames(
1440                   const CIMNamespaceName& nameSpace,
1441                   const CIMName& className,
1442                   Boolean deepInheritance)
1443               {
1444 mike  1.1.2.3     printf("===== MetaRepository::enumerateClassNames()\n");
1445               
1446               #if defined(TEST_META_REPOSITORY)
1447                   _init();
1448               #endif
1449               
1450 mike  1.1.2.1     // Lookup namespace:
1451               
1452                   const MetaNameSpace* ns = _findNameSpace(*Str(nameSpace));
1453               
1454                   if (!ns)
1455                       _throw(CIM_ERR_INVALID_NAMESPACE, "%s", *Str(nameSpace));
1456               
1457                   // Lookup class:
1458               
1459                   const MetaClass* super = 0;
1460                   
1461                   if (!className.isNull())
1462                   {
1463                       super = _findClass(ns, *Str(className));
1464               
1465                       if (!super)
1466                           _throw(CIM_ERR_NOT_FOUND, "unknown class: %s", *Str(className));
1467                   }
1468               
1469                   // Iterate all classes looking for matches:
1470               
1471 mike  1.1.2.1     Array<CIMName> result;
1472               
1473                   for (size_t i = 0; ns->classes[i]; i++)
1474                   {
1475 mike  1.1.2.3         MetaClass* mc = ns->classes[i];
1476 mike  1.1.2.1 
1477                       if (deepInheritance)
1478                       {
1479 mike  1.1.2.3             if (_isSubClass(super, mc))
1480                               result.append(mc->name);
1481 mike  1.1.2.1         }
1482                       else
1483                       {
1484 mike  1.1.2.3             if (_isDirectSubClass(super, mc))
1485                               result.append(mc->name);
1486 mike  1.1.2.1         }
1487                   }
1488               
1489                   return result;
1490               }
1491               
1492               void MetaRepository::deleteClass(
1493                   const CIMNamespaceName& nameSpace,
1494                   const CIMName& className)
1495               {
1496                   _throw(CIM_ERR_NOT_SUPPORTED, "deleteClass()");
1497               }
1498               
1499               void MetaRepository::createClass(
1500                   const CIMNamespaceName& nameSpace,
1501                   const CIMClass& newClass)
1502               {
1503                   _throw(CIM_ERR_NOT_SUPPORTED, "createClass()");
1504               }
1505               
1506               void MetaRepository::modifyClass(
1507 mike  1.1.2.1     const CIMNamespaceName& nameSpace,
1508                   const CIMClass& newClass)
1509               {
1510                   _throw(CIM_ERR_NOT_SUPPORTED, "modifyClass()");
1511               }
1512               
1513               PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2