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

  1 karl  1.14 //%2003////////////////////////////////////////////////////////////////////////
  2 mike  1.4  //
  3 karl  1.14 // 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 mike  1.4  //
  8 kumpf 1.8  // Permission is hereby granted, free of charge, to any person obtaining a copy
  9            // of this software and associated documentation files (the "Software"), to
 10            // deal in the Software without restriction, including without limitation the
 11            // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 12            // sell copies of the Software, and to permit persons to whom the Software is
 13            // furnished to do so, subject to the following conditions:
 14            // 
 15            // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 16            // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
 17            // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 18            // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 19            // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 20            // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 21            // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 22            // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 23 mike  1.4  //
 24 kumpf 1.8  //==============================================================================
 25 mike  1.4  //
 26            // Author: Mike Brasher (mbrasher@bmc.com)
 27            //
 28            // Modified By:  Bob Blair (bblair@bmc.com)
 29 kumpf 1.9  //              Carol Ann Krug Graves, Hewlett-Packard Company
 30            //                (carolann_graves@hp.com)
 31 gerarda 1.11 //              Gerarda Marquez (gmarquez@us.ibm.com)
 32              //              -- PEP 43 changes
 33 mike    1.4  //
 34 bob     1.5  //%////////////////////////////////////////////////////////////////////////////
 35 mike    1.4  
 36              
 37              #include "compilerDeclContext.h"
 38              
 39 bob     1.5  compilerDeclContext::compilerDeclContext(CIMRepository *repository,
 40              					compilerCommonDefs::operationType ot) :
 41                RepositoryDeclContext(repository), _cimRepository(repository), _ot(ot)
 42 mike    1.4  {
 43 bob     1.5    if (!repository && ot != compilerCommonDefs::IGNORE_REPOSITORY)
 44                  throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
 45              				"attempt to initialize repository with "
 46              				"invalid data");
 47 mike    1.4  }
 48              
 49              compilerDeclContext::~compilerDeclContext() {}
 50              
 51              CIMQualifierDecl
 52 kumpf   1.9  compilerDeclContext::lookupQualifierDecl(const CIMNamespaceName &nameSpace,
 53              					 const CIMName &qualifierName) const
 54 mike    1.4  {
 55                const CIMQualifierDecl *pTheQualifier = 0;
 56 bob     1.5    if (_ot != compilerCommonDefs::USE_REPOSITORY) {
 57 mike    1.4      if ( (pTheQualifier = 
 58              	  _findQualifierInMemory(qualifierName)) )
 59                    return *pTheQualifier;
 60                }
 61 bob     1.5    if (_repository && (_ot != compilerCommonDefs::IGNORE_REPOSITORY)) {
 62 kumpf   1.15       return _repository->_getQualifier(nameSpace, qualifierName);
 63 mike    1.4    }
 64                return CIMQualifierDecl();
 65              }
 66              
 67              CIMClass
 68 kumpf   1.9  compilerDeclContext::lookupClass(const CIMNamespaceName &nameSpace,
 69              				 const CIMName &className) const
 70 mike    1.4  {
 71                const CIMClass *pTheClass;
 72 karl    1.6  
 73 bob     1.5    if (_ot != compilerCommonDefs::USE_REPOSITORY) {
 74 mike    1.4      if ( (pTheClass =_findClassInMemory(className)) )
 75                    return *pTheClass;
 76                }
 77 bob     1.5    if (_repository && _ot != compilerCommonDefs::IGNORE_REPOSITORY) {
 78 kumpf   1.15       return _repository->_getClass(
 79                        nameSpace, className, false, true, true, CIMPropertyList());
 80 mike    1.4    }
 81                return CIMClass();
 82              }
 83              
 84              void
 85 kumpf   1.9  compilerDeclContext::addQualifierDecl(const CIMNamespaceName &nameSpace,
 86 mike    1.4  				      const CIMQualifierDecl &x)
 87              {
 88 bob     1.5    if (_ot != compilerCommonDefs::USE_REPOSITORY)
 89 mike    1.4      _qualifiers.append(x);
 90                else
 91 kumpf   1.15     _repository->_setQualifier(nameSpace, x);
 92 mike    1.4  }
 93              
 94              void
 95 kumpf   1.9  compilerDeclContext::addClass(const CIMNamespaceName &nameSpace, CIMClass &x)
 96 mike    1.4  {
 97 bob     1.5    if (_ot != compilerCommonDefs::USE_REPOSITORY)
 98 mike    1.4      _classes.append(x);
 99                else
100 kumpf   1.15     _repository->_createClass(nameSpace, x);
101 bob     1.5  }
102              
103              void
104 kumpf   1.9  compilerDeclContext::addInstance(const CIMNamespaceName &nameSpace, 
105                                               CIMInstance &x)
106 bob     1.5  {
107                if (_ot == compilerCommonDefs::USE_REPOSITORY)
108 kumpf   1.15     _repository->_createInstance(nameSpace, x);
109 gerarda 1.11 }
110              
111              void
112              compilerDeclContext::modifyClass(const CIMNamespaceName &nameSpace, CIMClass &x)
113              {
114                if (_ot != compilerCommonDefs::USE_REPOSITORY)
115                {
116                  _classes.append(x);
117                }
118                else
119                {
120 kumpf   1.15     _repository->_modifyClass(nameSpace, x);
121 gerarda 1.11   }
122 mike    1.4  }
123              
124              const CIMClass *
125 kumpf   1.9  compilerDeclContext::_findClassInMemory(const CIMName &classname) const
126 mike    1.4  {
127                for (unsigned int i = 0; i < _classes.size(); i++) {
128 kumpf   1.10     if (classname.equal (_classes[i].getClassName()))
129 mike    1.4  	return &(_classes[i]);
130                }
131                return 0;
132              }
133              
134              const CIMQualifierDecl *
135 kumpf   1.9  compilerDeclContext::_findQualifierInMemory(const CIMName &classname) const
136 mike    1.4  {
137                for (unsigned int i = 0; i < _qualifiers.size(); i++) {
138 kumpf   1.10     if (classname.equal (_qualifiers[i].getName()))
139 mike    1.4  	return &(_qualifiers[i]);
140                }
141                return 0;
142              }

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2