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

  1 karl  1.19 //%2006////////////////////////////////////////////////////////////////////////
  2 mike  1.4  //
  3 karl  1.17 // 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 karl  1.14 // IBM Corp.; EMC Corporation, The Open Group.
  7 karl  1.17 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
  8            // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
  9 karl  1.18 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 10            // EMC Corporation; VERITAS Software Corporation; The Open Group.
 11 karl  1.19 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 12            // EMC Corporation; Symantec Corporation; The Open Group.
 13 mike  1.4  //
 14 kumpf 1.8  // 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            // 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 mike  1.4  //
 30 kumpf 1.8  //==============================================================================
 31 mike  1.4  //
 32            // Author: Mike Brasher (mbrasher@bmc.com)
 33            //
 34            // Modified By:  Bob Blair (bblair@bmc.com)
 35 kumpf 1.9  //              Carol Ann Krug Graves, Hewlett-Packard Company
 36            //                (carolann_graves@hp.com)
 37 gerarda 1.11 //              Gerarda Marquez (gmarquez@us.ibm.com)
 38              //              -- PEP 43 changes
 39 mike    1.4  //
 40 bob     1.5  //%////////////////////////////////////////////////////////////////////////////
 41 mike    1.4  
 42              
 43              #include "compilerDeclContext.h"
 44 mike    1.19.30.1 #include "Policy.h"
 45 mike    1.4       
 46 kumpf   1.16      PEGASUS_NAMESPACE_BEGIN
 47                   
 48 bob     1.5       compilerDeclContext::compilerDeclContext(CIMRepository *repository,
 49                   					compilerCommonDefs::operationType ot) :
 50                     RepositoryDeclContext(repository), _cimRepository(repository), _ot(ot)
 51 mike    1.4       {
 52 bob     1.5         if (!repository && ot != compilerCommonDefs::IGNORE_REPOSITORY)
 53                       throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
 54                   				"attempt to initialize repository with "
 55                   				"invalid data");
 56 mike    1.4       }
 57                   
 58                   compilerDeclContext::~compilerDeclContext() {}
 59                   
 60                   CIMQualifierDecl
 61 kumpf   1.9       compilerDeclContext::lookupQualifierDecl(const CIMNamespaceName &nameSpace,
 62                   					 const CIMName &qualifierName) const
 63 mike    1.4       {
 64                     const CIMQualifierDecl *pTheQualifier = 0;
 65 bob     1.5         if (_ot != compilerCommonDefs::USE_REPOSITORY) {
 66 mike    1.4           if ( (pTheQualifier = 
 67                   	  _findQualifierInMemory(qualifierName)) )
 68                         return *pTheQualifier;
 69                     }
 70 bob     1.5         if (_repository && (_ot != compilerCommonDefs::IGNORE_REPOSITORY)) {
 71 kumpf   1.15            return _repository->_getQualifier(nameSpace, qualifierName);
 72 mike    1.4         }
 73                     return CIMQualifierDecl();
 74                   }
 75                   
 76                   CIMClass
 77 kumpf   1.9       compilerDeclContext::lookupClass(const CIMNamespaceName &nameSpace,
 78                   				 const CIMName &className) const
 79 mike    1.4       {
 80                     const CIMClass *pTheClass;
 81 karl    1.6       
 82 bob     1.5         if (_ot != compilerCommonDefs::USE_REPOSITORY) {
 83 mike    1.4           if ( (pTheClass =_findClassInMemory(className)) )
 84                         return *pTheClass;
 85                     }
 86 bob     1.5         if (_repository && _ot != compilerCommonDefs::IGNORE_REPOSITORY) {
 87 kumpf   1.15            return _repository->_getClass(
 88                             nameSpace, className, false, true, true, CIMPropertyList());
 89 mike    1.4         }
 90                     return CIMClass();
 91                   }
 92                   
 93                   void
 94 kumpf   1.9       compilerDeclContext::addQualifierDecl(const CIMNamespaceName &nameSpace,
 95 mike    1.4       				      const CIMQualifierDecl &x)
 96                   {
 97 bob     1.5         if (_ot != compilerCommonDefs::USE_REPOSITORY)
 98 mike    1.4           _qualifiers.append(x);
 99                     else
100 kumpf   1.15          _repository->_setQualifier(nameSpace, x);
101 mike    1.4       }
102                   
103                   void
104 kumpf   1.9       compilerDeclContext::addClass(const CIMNamespaceName &nameSpace, CIMClass &x)
105 mike    1.4       {
106 bob     1.5         if (_ot != compilerCommonDefs::USE_REPOSITORY)
107 mike    1.4           _classes.append(x);
108                     else
109 kumpf   1.15          _repository->_createClass(nameSpace, x);
110 bob     1.5       }
111                   
112                   void
113 kumpf   1.9       compilerDeclContext::addInstance(const CIMNamespaceName &nameSpace, 
114                                                    CIMInstance &x)
115 bob     1.5       {
116                     if (_ot == compilerCommonDefs::USE_REPOSITORY)
117 mike    1.19.30.1   {
118 kumpf   1.15          _repository->_createInstance(nameSpace, x);
119 mike    1.19.30.1 
120 mike    1.19.30.2 #if defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION)
121                   
122 mike    1.19.30.1     // If the class name is "PG_ProviderModule", then the policy file must
123                       // be updated before asking the CIM server to create the instance.
124                   
125                       String className = x.getClassName().getString();
126                   
127                       if (String::equalNoCase(className, "PG_ProviderModule"))
128                           UpdatePolicyFile(0, nameSpace, x);
129 mike    1.19.30.2 
130                   #endif /* defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION) */
131 mike    1.19.30.1   }
132 gerarda 1.11      }
133                   
134                   void
135                   compilerDeclContext::modifyClass(const CIMNamespaceName &nameSpace, CIMClass &x)
136                   {
137                     if (_ot != compilerCommonDefs::USE_REPOSITORY)
138                     {
139                       _classes.append(x);
140                     }
141                     else
142                     {
143 kumpf   1.15          _repository->_modifyClass(nameSpace, x);
144 gerarda 1.11        }
145 mike    1.4       }
146                   
147                   const CIMClass *
148 kumpf   1.9       compilerDeclContext::_findClassInMemory(const CIMName &classname) const
149 mike    1.4       {
150                     for (unsigned int i = 0; i < _classes.size(); i++) {
151 kumpf   1.10          if (classname.equal (_classes[i].getClassName()))
152 mike    1.4       	return &(_classes[i]);
153                     }
154                     return 0;
155                   }
156                   
157                   const CIMQualifierDecl *
158 kumpf   1.9       compilerDeclContext::_findQualifierInMemory(const CIMName &classname) const
159 mike    1.4       {
160                     for (unsigned int i = 0; i < _qualifiers.size(); i++) {
161 kumpf   1.10          if (classname.equal (_qualifiers[i].getName()))
162 mike    1.4       	return &(_qualifiers[i]);
163                     }
164                     return 0;
165                   }
166 kumpf   1.16      
167                   PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2