(file) Return to compilerDeclContext.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Compiler

  1 bob   1.1 //%/////////////////////////////////////////////////////////////////////////////
  2           //
  3           // Copyright (c) 2000 The Open Group, BMC Software, Tivoli Systems, IBM
  4           //
  5           // Permission is hereby granted, free of charge, to any person obtaining a
  6           // copy of this software and associated documentation files (the "Software"),
  7           // to deal in the Software without restriction, including without limitation
  8           // the rights to use, copy, modify, merge, publish, distribute, sublicense,
  9           // and/or sell copies of the Software, and to permit persons to whom the
 10           // Software is furnished to do so, subject to the following conditions:
 11           //
 12           // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 13           // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 14           // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
 15           // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 16           // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 17           // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 18           // DEALINGS IN THE SOFTWARE.
 19           //
 20           //==============================================================================
 21           //
 22 bob   1.1 // Author: Mike Brasher (mbrasher@bmc.com)
 23           //
 24           // Modified By:  Bob Blair (bblair@bmc.com)
 25           //
 26           //%/////////////////////////////////////////////////////////////////////////////
 27           
 28           
 29           #include "compilerDeclContext.h"
 30           
 31           compilerDeclContext::compilerDeclContext(cimmofRepository *repository,
 32           					 cimmofRepository::operationType ot) :
 33             RepositoryDeclContext(repository), _cimmofRepository(repository), _ot(ot)
 34           {
 35           }
 36           
 37           compilerDeclContext::~compilerDeclContext() {}
 38           
 39           CIMQualifierDecl
 40           compilerDeclContext::lookupQualifierDecl(const String &nameSpace,
 41           					 const String &qualifierName) const
 42           {
 43 bob   1.1   const CIMQualifierDecl *pTheQualifier = 0;
 44             if (_ot != cimmofRepository::USE_REPOSITORY) {
 45               if ( (pTheQualifier = 
 46           	  _findQualifierInMemory(qualifierName)) )
 47                 return *pTheQualifier;
 48             }
 49             if (_repository && (_ot != cimmofRepository::IGNORE_REPOSITORY)) {
 50               try {
 51                 return _repository->getQualifier(nameSpace, qualifierName);
 52               } catch (Exception &e) {
 53                 // FIXME:  catch the NOT_FOUND condition.  Don't catch others.
 54                 // ignore.  It either isn't there or something's broken.
 55               }
 56             }
 57             return CIMQualifierDecl();
 58           }
 59           
 60           CIMClass
 61           compilerDeclContext::lookupClass(const String &nameSpace,
 62           				 const String &className) const
 63           {
 64 bob   1.1   const CIMClass *pTheClass;
 65             if (_ot != cimmofRepository::USE_REPOSITORY) {
 66               if ( (pTheClass =_findClassInMemory(className)) )
 67                 return *pTheClass;
 68             }
 69             if (_repository && _ot != cimmofRepository::IGNORE_REPOSITORY) {
 70               try {
 71                 return _repository->getClass(nameSpace, className);
 72               } catch(Exception &e) {
 73                 // ignore failure to find.  FIXME:  pass others on.
 74               }
 75             }
 76             return CIMClass();
 77           }
 78           
 79           void
 80           compilerDeclContext::addQualifierDecl(const String &nameSpace,
 81           				      const CIMQualifierDecl &x)
 82           {
 83             if (_ot != cimmofRepository::USE_REPOSITORY)
 84               _qualifiers.append(x);
 85 bob   1.1   else
 86               _repository->setQualifier(nameSpace, x);
 87           }
 88           
 89           void
 90           compilerDeclContext::addClass(const String &nameSpace, CIMClass &x)
 91           {
 92             if (_ot != cimmofRepository::USE_REPOSITORY)
 93               _classes.append(x);
 94             else
 95               _repository->createClass(nameSpace, x);
 96           }
 97           
 98           const CIMClass *
 99           compilerDeclContext::_findClassInMemory(const String &classname) const
100           {
101             for (unsigned int i = 0; i < _classes.size(); i++) {
102               if (String::equal(classname, (_classes[i]).getClassName()))
103           	return &(_classes[i]);
104             }
105             return 0;
106 bob   1.1 }
107           
108           const CIMQualifierDecl *
109           compilerDeclContext::_findQualifierInMemory(const String &classname) const
110           {
111             for (unsigned int i = 0; i < _qualifiers.size(); i++) {
112               if (String::equal(classname, (_qualifiers[i]).getName()))
113           	return &(_qualifiers[i]);
114             }
115             return 0;
116           }

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2