Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1321 lines
42 KiB

  1. /*++
  2. Copyright (C) 1996-1999 Microsoft Corporation
  3. Module Name:
  4. EVALTREE.H
  5. Abstract:
  6. WBEM Evaluation Tree
  7. History:
  8. --*/
  9. #ifndef __WBEM_EVALUTAION_TREE__H_
  10. #define __WBEM_EVALUTAION_TREE__H_
  11. #include "esscpol.h"
  12. #include <parmdefs.h>
  13. #include <ql.h>
  14. #include <sync.h>
  15. #include <limits.h>
  16. #include <sortarr.h>
  17. #include <newnew.h>
  18. #include <wbemmeta.h>
  19. #include <wbemdnf.h>
  20. #include <fastall.h>
  21. #include <like.h>
  22. // Uncomment this to enable tree checking.
  23. //#define CHECK_TREES
  24. #ifdef CHECK_TREES
  25. class CTreeChecker;
  26. #endif
  27. typedef DWORD_PTR QueryID;
  28. #define InvalidID UINT_MAX
  29. enum {EVAL_VALUE_TRUE, EVAL_VALUE_FALSE, EVAL_VALUE_INVALID};
  30. #define WBEM_FLAG_MANDATORY_MERGE 0x100
  31. // This is where we keep the extracted embedded objects
  32. class ESSCLI_POLARITY CObjectInfo
  33. {
  34. protected:
  35. long m_lLength;
  36. _IWmiObject** m_apObj;
  37. public:
  38. CObjectInfo() : m_apObj(NULL), m_lLength(0){}
  39. ~CObjectInfo();
  40. long GetLength() {return m_lLength;}
  41. bool SetLength(long lLength);
  42. void Clear();
  43. INTERNAL _IWmiObject* GetObjectAt(long lIndex)
  44. {return m_apObj[lIndex];}
  45. void SetObjectAt(long lIndex, READ_ONLY _IWmiObject* pObj);
  46. };
  47. // This is where we keep what we've learned about the object in the query
  48. // as we move down the tree.
  49. class CImplicationList
  50. {
  51. public:
  52. struct CRecord
  53. {
  54. CPropertyName m_PropName;
  55. _IWmiObject* m_pClass;
  56. long m_lObjIndex;
  57. CWStringArray m_awsNotClasses;
  58. int m_nNull;
  59. public:
  60. CRecord(CPropertyName& PropName, long lObjIndex)
  61. : m_PropName(PropName), m_pClass(NULL), m_lObjIndex(lObjIndex),
  62. m_nNull(EVAL_VALUE_INVALID)
  63. {}
  64. CRecord(const CRecord& Other);
  65. ~CRecord();
  66. HRESULT ImproveKnown(_IWmiObject* pClass);
  67. HRESULT ImproveKnownNot(LPCWSTR wszClassName);
  68. HRESULT ImproveKnownNull();
  69. void Dump(FILE* f, int nOffset);
  70. };
  71. protected:
  72. long m_lRequiredDepth;
  73. CUniquePointerArray<CRecord> m_apRecords;
  74. long m_lNextIndex;
  75. CImplicationList* m_pParent;
  76. long m_lFlags;
  77. protected:
  78. void FindBestComputedContainer(CPropertyName* pPropName,
  79. long* plRecord, long* plMatched);
  80. HRESULT MergeIn(CImplicationList::CRecord* pRecord);
  81. HRESULT FindRecordForProp(CPropertyName* pPropName, long lNumElements,
  82. long* plRecord);
  83. HRESULT FindOrCreateRecordForProp(CPropertyName* pPropName,
  84. CImplicationList::CRecord** ppRecord);
  85. public:
  86. CImplicationList(long lFlags = 0);
  87. CImplicationList(CImplicationList& Other, bool bLink = true);
  88. ~CImplicationList();
  89. HRESULT FindBestComputedContainer(CPropertyName* pPropName,
  90. long* plFirstUnknownProp, long* plObjIndex,
  91. RELEASE_ME _IWmiObject** ppContainerClass);
  92. HRESULT FindClassForProp(CPropertyName* pPropName,
  93. long lNumElements, RELEASE_ME _IWmiObject** ppClass);
  94. HRESULT AddComputation(CPropertyName& PropName,
  95. _IWmiObject* pClass, long* plObjIndex);
  96. HRESULT MergeIn(CImplicationList* pList);
  97. long GetRequiredDepth();
  98. void RequireDepth(long lDepth);
  99. HRESULT ImproveKnown(CPropertyName* pPropName, _IWmiObject* pClass);
  100. HRESULT ImproveKnownNot(CPropertyName* pPropName, LPCWSTR wszClassName);
  101. HRESULT ImproveKnownNull(CPropertyName* pPropName);
  102. bool IsMergeMandatory()
  103. {return ((m_lFlags & WBEM_FLAG_MANDATORY_MERGE) != 0);}
  104. bool IsEmpty() {return m_apRecords.GetSize() == 0;}
  105. void Dump(FILE* f, int nOffset);
  106. };
  107. // Wrapper for arbitrary values
  108. class CTokenValue
  109. {
  110. protected:
  111. VARIANT m_v;
  112. public:
  113. CTokenValue();
  114. CTokenValue(CTokenValue& Other);
  115. ~CTokenValue();
  116. bool SetVariant(VARIANT& v);
  117. void operator=(CTokenValue& Other);
  118. operator signed char() const {return (signed char)V_I4(&m_v);}
  119. operator unsigned char() const {return (unsigned char)V_I4(&m_v);}
  120. operator unsigned short() const {return (unsigned short)V_I4(&m_v);}
  121. operator long() const {return (long)V_I4(&m_v);}
  122. operator unsigned long() const;
  123. operator __int64() const;
  124. operator unsigned __int64() const;
  125. operator float() const;
  126. operator double() const;
  127. operator short() const;
  128. operator WString() const;
  129. operator CInternalString() const {return CInternalString((WString)*this);}
  130. int Compare(const CTokenValue& Other) const;
  131. BOOL operator<(const CTokenValue& Other) const
  132. {return Compare(Other) < 0;}
  133. BOOL operator>(const CTokenValue& Other) const
  134. {return Compare(Other) > 0;}
  135. BOOL operator==(const CTokenValue& Other) const
  136. {return Compare(Other) == 0;}
  137. };
  138. enum {EVAL_OP_AND, EVAL_OP_OR, EVAL_OP_COMBINE, EVAL_OP_INVERSE_COMBINE};
  139. inline int FlipEvalOp(int nOp)
  140. {
  141. if(nOp == EVAL_OP_COMBINE) return EVAL_OP_INVERSE_COMBINE;
  142. else if(nOp == EVAL_OP_INVERSE_COMBINE) return EVAL_OP_COMBINE;
  143. else return nOp;
  144. }
  145. enum
  146. {
  147. EVAL_NODE_TYPE_VALUE,
  148. EVAL_NODE_TYPE_BRANCH,
  149. EVAL_NODE_TYPE_OR,
  150. EVAL_NODE_TYPE_INHERITANCE,
  151. EVAL_NODE_TYPE_SCALAR,
  152. EVAL_NODE_TYPE_TWO_SCALARS,
  153. EVAL_NODE_TYPE_STRING,
  154. EVAL_NODE_TYPE_TWO_STRINGS,
  155. EVAL_NODE_TYPE_MISMATCHED_INTS,
  156. EVAL_NODE_TYPE_MISMATCHED_FLOATS,
  157. EVAL_NODE_TYPE_MISMATCHED_STRINGS,
  158. EVAL_NODE_TYPE_DUMB,
  159. EVAL_NODE_TYPE_LIKE_STRING
  160. };
  161. // Base class for all sorts of operations one can perform on leaf nodes of a
  162. // tree. When applied to a leaf, it can change it, and return a value from the
  163. // list below to control the rest of the traversal
  164. enum
  165. {
  166. WBEM_DISPOSITION_NORMAL = 0,
  167. WBEM_DISPOSITION_STOPLEVEL = 1,
  168. WBEM_DISPOSITION_STOPALL = 2,
  169. WBEM_DISPOSITION_FLAG_DELETE = 16,
  170. WBEM_DISPOSITION_FLAG_INVALIDATE = 32
  171. };
  172. class CLeafPredicate
  173. {
  174. public:
  175. virtual DWORD operator()(class CValueNode* pLeaf) = 0;
  176. };
  177. class CProjectionFilter
  178. {
  179. public:
  180. virtual bool IsInSet(class CEvalNode* pNode) = 0;
  181. };
  182. typedef enum {e_Sufficient, e_Necessary} EProjectionType;
  183. // Base class for all nodes in the tree
  184. class ESSCLI_POLARITY CEvalNode
  185. {
  186. protected:
  187. // int m_nType;
  188. virtual int GetType() = 0;
  189. public:
  190. CEvalNode();
  191. CEvalNode(const CEvalNode& other);
  192. virtual ~CEvalNode();
  193. // NULL EvalNode interpreted as a Value Node with all false
  194. static int GetType(CEvalNode *pNode)
  195. {
  196. if (pNode)
  197. return pNode->GetType();
  198. else
  199. return EVAL_NODE_TYPE_VALUE;
  200. }
  201. virtual CEvalNode* Clone() const = 0;
  202. virtual HRESULT CombineWith(CEvalNode* pArg2, int nOp,
  203. CContextMetaData* pNamespace, CImplicationList& Implications,
  204. bool bDeleteThis, bool bDeleteArg2, CEvalNode** ppRes)=0;
  205. virtual int Compare(CEvalNode* pOther) = 0;
  206. virtual DWORD ApplyPredicate(CLeafPredicate* pPred) = 0;
  207. virtual void Dump(FILE* f, int nOffset) = 0;
  208. #ifdef CHECK_TREES
  209. virtual void CheckNode(CTreeChecker *pCheck);
  210. #endif
  211. virtual HRESULT Optimize(CContextMetaData* pNamespace, CEvalNode** ppNew)
  212. {*ppNew = this; return WBEM_S_NO_ERROR;}
  213. virtual bool IsInvalid() {return false;}
  214. static bool IsInvalid(CEvalNode* pNode)
  215. {
  216. if(pNode)
  217. return pNode->IsInvalid();
  218. else
  219. return false;
  220. }
  221. virtual bool IsAllFalse() {return false;}
  222. static bool IsAllFalse(CEvalNode* pNode)
  223. {
  224. if(pNode)
  225. return pNode->IsAllFalse();
  226. else
  227. return true; // empty node is FALSE
  228. }
  229. virtual bool IsNoop(int nOp) {return false;}
  230. static bool IsNoop(CEvalNode* pNode, int nOp);
  231. virtual CImplicationList* GetExtraImplications() = 0;
  232. virtual HRESULT SetExtraImplications(CImplicationList* pList) = 0;
  233. static void PrintOffset(FILE* f, int nOffset);
  234. static CEvalNode* CloneNode(const CEvalNode* pNode);
  235. virtual HRESULT Project(CContextMetaData* pMeta,
  236. CImplicationList& Implications,
  237. CProjectionFilter* pFilter,
  238. EProjectionType eType, bool bDeleteThis,
  239. CEvalNode** ppNewNode) = 0;
  240. static void DumpNode(FILE* f, int nOffset, CEvalNode* pNode);
  241. };
  242. // just like CFlexArray, except:
  243. // array is always sorted
  244. // duplicates are not allowed
  245. // deals with QueryIDs (unsigneds), rather than pointers
  246. // intended for use by CValueNode, not necessarily as a generic sorted array
  247. // ASSUMPTION: pointer is same size as an unsigned
  248. class ESSCLI_POLARITY CSortedArray : protected CFlexArray
  249. {
  250. public:
  251. // Constructs a sorted array at an initial size and
  252. // specifies the initial size and growth-size chunk.
  253. // =================================================
  254. CSortedArray(int nInitialSize = 32,
  255. int nGrowBy = 32
  256. ) : CFlexArray(nInitialSize, nGrowBy)
  257. {}
  258. CSortedArray(unsigned nElements, QueryID* pArray);
  259. // ~CSortedArray(); don't need it, yet...
  260. void operator=(const CSortedArray &that)
  261. {((CFlexArray&)*this = (CFlexArray&)that); }
  262. int inline Size() const { return CFlexArray::Size(); }
  263. inline QueryID GetAt(int nIndex)
  264. { return (QueryID)CFlexArray::GetAt(nIndex); }
  265. inline void Empty() { CFlexArray::Empty(); }
  266. inline void SetSize(int nSize) {CFlexArray::SetSize(nSize);}
  267. void DebugDump() { CFlexArray::DebugDump(); }
  268. // copies this array to destination
  269. // returns number of elements copied
  270. unsigned CopyTo(QueryID* pDest, unsigned size);
  271. //returns zero if arrays are equivalent
  272. // same number of USED elements w/ same values
  273. int Compare(CSortedArray& otherArray);
  274. // finds n in array
  275. // return index of found element
  276. // returns -1 if not found
  277. unsigned Find(QueryID n);
  278. // inserts n in proper position in array
  279. void Insert(QueryID n);
  280. // removes n from array
  281. // returns true if it did
  282. bool Remove(QueryID n);
  283. // add to end of array
  284. inline int Add(QueryID n) { return CFlexArray::Add((void *)n); };
  285. // changes all QueryID's to begin at newBase
  286. // e.g. if the array is {0,1,5}
  287. // Rebase(6) will change to {6,7,11}
  288. void Rebase(QueryID newBase);
  289. // Retrieves internal pointer to the data in the array
  290. inline QueryID* GetArrayPtr() {return (QueryID*)CFlexArray::GetArrayPtr();}
  291. // Retrieves the pointer to the data in the array and empties the array
  292. // The caller is responsible for the memory returned
  293. inline QueryID* UnbindPtr() {return (QueryID*)CFlexArray::UnbindPtr();}
  294. // Copies the data (but not the extent) from another array
  295. // Its own data is overwritten
  296. inline int CopyDataFrom(const CSortedArray& aOther)
  297. {return CFlexArray::CopyDataFrom(aOther);}
  298. int AddDataFrom(const CSortedArray& aOther);
  299. int AddDataFrom(const QueryID* pOtherArray, unsigned nValues);
  300. int CopyDataFrom(const QueryID* pArray, unsigned nElements);
  301. protected:
  302. };
  303. // Leaf node --- contains the list of queries that matched
  304. class CValueNode : public CEvalNode
  305. {
  306. protected:
  307. DWORD m_nValues;
  308. // this data member MUST be the last in the class
  309. // to allow an array size defined at runtime
  310. // this array is always assumed to be sorted
  311. QueryID m_trueIDs[1];
  312. void ORarrays(CSortedArray& array1, CSortedArray& array1Not,
  313. CSortedArray& array2, CSortedArray& array2Not,
  314. CSortedArray& output);
  315. void ORarrays(CSortedArray& array1,
  316. CSortedArray& array2,
  317. CSortedArray& output);
  318. unsigned ORarrays(QueryID* pArray1, unsigned size1,
  319. QueryID* pArray2, unsigned size2,
  320. QueryID* pOutput);
  321. void ANDarrays(CSortedArray& array1, CSortedArray& array2,
  322. CSortedArray& output);
  323. unsigned ANDarrays(QueryID* pArray1, unsigned size1,
  324. QueryID* pArray2, unsigned size2,
  325. QueryID* pOutput);
  326. void CombineArrays(CSortedArray& array1, CSortedArray& array2,
  327. CSortedArray& output);
  328. unsigned CombineArrays(QueryID* pArray1, unsigned size1,
  329. QueryID* pArray2, unsigned size2,
  330. QueryID* pOutput);
  331. // ctors moved to 'protected' to force callers to use the CreateNode function
  332. CValueNode()
  333. {}
  334. CValueNode(int nNumValues);
  335. virtual int GetType();
  336. public:
  337. virtual ~CValueNode();
  338. static CValueNode* CreateNode(size_t nNumValues);
  339. static CValueNode* CreateNode(CSortedArray& values);
  340. void *operator new( size_t stAllocateBlock, unsigned nEntries = 0);
  341. // VC 5 only allows one delete operator per class
  342. #if _MSC_VER >= 1200
  343. void operator delete( void *p, unsigned nEntries );
  344. #endif
  345. void operator delete(void* p) { ::delete[] (byte*)p; };
  346. // changes all QueryID's to begin at newBase
  347. // e.g. if the array is {0,1,5}
  348. // Rebase(6) will change to {6,7,11}
  349. DWORD GetNumTrues() {return m_nValues;}
  350. void Rebase(QueryID newBase);
  351. unsigned FindQueryID(QueryID n);
  352. int GetAt(int nIndex)
  353. {
  354. if (FindQueryID(nIndex) != InvalidID)
  355. return EVAL_VALUE_TRUE;
  356. else
  357. return EVAL_VALUE_FALSE;
  358. }
  359. bool IsAllFalse()
  360. {
  361. return (m_nValues == 0);
  362. }
  363. static bool IsAllFalse(CValueNode* pNode)
  364. {
  365. if (pNode)
  366. return pNode->IsAllFalse();
  367. else
  368. return true;
  369. }
  370. static bool IsNoop(CValueNode* pNode, int nOp);
  371. bool IsNoop(int nOp)
  372. {
  373. return IsNoop(this, nOp);
  374. }
  375. static bool AreAnyTrue(CValueNode* pNode)
  376. {
  377. if (pNode)
  378. return (pNode->m_nValues > 0);
  379. else
  380. return false;
  381. }
  382. CEvalNode* Clone() const;
  383. HRESULT CombineWith(CEvalNode* pArg2, int nOp,
  384. CContextMetaData* pNamespace, CImplicationList& Implications,
  385. bool bDeleteThis, bool bDeleteArg2, CEvalNode** ppRes);
  386. int Compare(CEvalNode* pOther);
  387. HRESULT TryShortCircuit(CEvalNode* pArg2, int nOp, bool bDeleteThis,
  388. bool bDeleteArg2, CEvalNode** ppRes);
  389. DWORD ApplyPredicate(CLeafPredicate* pPred) {return (*pPred)(this);}
  390. bool RemoveQueryID(QueryID nQuery);
  391. void CopyTruesTo(CSortedArray& trueIDs) const
  392. {trueIDs.CopyDataFrom(m_trueIDs, m_nValues);}
  393. void AddTruesTo(CSortedArray& trueIDs) const
  394. {
  395. int nWasSize = trueIDs.Size();
  396. if(nWasSize == 0)
  397. trueIDs.CopyDataFrom((QueryID*)&m_trueIDs, m_nValues);
  398. else if (m_nValues > 0)
  399. trueIDs.AddDataFrom((QueryID*)&m_trueIDs, m_nValues);
  400. }
  401. static CValueNode* GetStandardTrue();
  402. static CValueNode* GetStandardFalse() { return NULL; };
  403. static CValueNode* GetStandardInvalid();
  404. virtual CImplicationList* GetExtraImplications() {return NULL;}
  405. virtual HRESULT SetExtraImplications(CImplicationList* pList)
  406. {
  407. // CValueNodes don't use or need this, so just delete it.
  408. delete pList;
  409. return S_OK;
  410. }
  411. virtual HRESULT Project(CContextMetaData* pMeta,
  412. CImplicationList& Implications,
  413. CProjectionFilter* pFilter,
  414. EProjectionType eType, bool bDeleteThis,
  415. CEvalNode** ppNewNode);
  416. virtual void Dump(FILE* f, int nOffset);
  417. };
  418. class CInvalidNode : public CValueNode
  419. {
  420. public:
  421. CInvalidNode() : CValueNode(0){}
  422. bool IsInvalid() {return true;}
  423. void Dump(FILE* f, int nOffset);
  424. };
  425. // Contains information about the portion of the node exclusing the last
  426. // component of the property name
  427. class CEmbeddingInfo
  428. {
  429. protected:
  430. CPropertyName m_EmbeddedObjPropName;
  431. long m_lStartingObjIndex;
  432. long m_lNumJumps;
  433. struct JumpInfo {
  434. long lJump;
  435. long lTarget;
  436. }* m_aJumps;
  437. public:
  438. CEmbeddingInfo();
  439. CEmbeddingInfo(const CEmbeddingInfo& Other);
  440. ~CEmbeddingInfo();
  441. void operator=(const CEmbeddingInfo& Other);
  442. CPropertyName* GetEmbeddedObjPropName() {return &m_EmbeddedObjPropName;}
  443. void SetEmbeddedObjPropName(CPropertyName& Name)
  444. {m_EmbeddedObjPropName = Name;}
  445. bool SetPropertyNameButLast(const CPropertyName& Name);
  446. BOOL operator==(const CEmbeddingInfo& Other);
  447. BOOL operator!=(const CEmbeddingInfo& Other)
  448. {return !(*this == Other);}
  449. HRESULT Compile(CContextMetaData* pNamespace,
  450. CImplicationList& Implications,
  451. _IWmiObject** ppResultClass);
  452. HRESULT GetContainerObject(CObjectInfo& ObjInfo,
  453. INTERNAL _IWmiObject** ppInst);
  454. int ComparePrecedence(const CEmbeddingInfo* pOther);
  455. bool AreJumpsRelated( const CEmbeddingInfo* pInfo );
  456. bool MixInJumps(const CEmbeddingInfo* pInfo );
  457. bool IsEmpty() const;
  458. void Dump(FILE* f);
  459. };
  460. // A node that is interested in the implications that have accrued
  461. class CNodeWithImplications : public CEvalNode
  462. {
  463. protected:
  464. CImplicationList* m_pExtraImplications;
  465. public:
  466. CNodeWithImplications() : m_pExtraImplications(NULL){}
  467. CNodeWithImplications(const CNodeWithImplications& Other);
  468. ~CNodeWithImplications()
  469. {
  470. delete m_pExtraImplications;
  471. }
  472. virtual CImplicationList* GetExtraImplications()
  473. {
  474. return m_pExtraImplications;
  475. }
  476. virtual HRESULT SetExtraImplications(ACQUIRE CImplicationList* pList)
  477. {
  478. if(m_pExtraImplications)
  479. delete m_pExtraImplications;
  480. m_pExtraImplications = pList;
  481. return S_OK;
  482. }
  483. void Dump(FILE* f, int nOffset);
  484. };
  485. class CBranchIterator
  486. {
  487. public:
  488. virtual ~CBranchIterator(){}
  489. virtual INTERNAL CEvalNode* GetNode() = 0;
  490. virtual void SetNode(ACQUIRE CEvalNode* pNode) = 0;
  491. virtual bool IsValid() = 0;
  492. virtual void Advance() = 0;
  493. virtual HRESULT RecordBranch(CContextMetaData* pMeta,
  494. CImplicationList& Implications) = 0;
  495. };
  496. // A node with a test and a whole bunch of branches, including a special one for
  497. // the case where the thing being tested was NULL
  498. class CBranchingNode : public CNodeWithImplications
  499. {
  500. // protected:
  501. public: // because I don't know how to make a template a friend
  502. CUniquePointerArray<CEvalNode> m_apBranches;
  503. CEvalNode* m_pNullBranch;
  504. CEmbeddingInfo* m_pInfo;
  505. protected:
  506. void operator=(const CBranchingNode& Other);
  507. HRESULT CompileEmbeddingPortion(CContextMetaData* pNamespace,
  508. CImplicationList& Implications,
  509. _IWmiObject** ppResultClass)
  510. {
  511. if (!m_pInfo)
  512. return WBEM_S_NO_ERROR;
  513. else
  514. return m_pInfo->Compile(pNamespace, Implications, ppResultClass);
  515. }
  516. HRESULT GetContainerObject(CObjectInfo& ObjInfo,
  517. INTERNAL _IWmiObject** ppInst)
  518. {
  519. if (!m_pInfo)
  520. {
  521. // this SEEMS to be the behavior of the code prior to changes
  522. *ppInst = ObjInfo.GetObjectAt(0);
  523. return WBEM_S_NO_ERROR;
  524. }
  525. else
  526. return m_pInfo->GetContainerObject(ObjInfo, ppInst);
  527. }
  528. bool SetEmbeddedObjPropName(CPropertyName& Name);
  529. bool MixInJumps(const CEmbeddingInfo* pInfo);
  530. HRESULT StoreBranchImplications(CContextMetaData* pNamespace,
  531. int nBranchIndex, CEvalNode* pResult);
  532. public:
  533. CBranchingNode();
  534. CBranchingNode(const CBranchingNode& Other, BOOL bChildren = TRUE);
  535. ~CBranchingNode();
  536. virtual int GetType();
  537. virtual long GetSubType() = 0;
  538. CUniquePointerArray<CEvalNode>& GetBranches() {return m_apBranches;}
  539. CEvalNode* GetNullBranch() {return m_pNullBranch;}
  540. void SetNullBranch(CEvalNode* pBranch);
  541. CPropertyName* GetEmbeddedObjPropName()
  542. {
  543. if (!m_pInfo)
  544. return NULL;
  545. else
  546. return m_pInfo->GetEmbeddedObjPropName();
  547. }
  548. virtual DWORD ApplyPredicate(CLeafPredicate* pPred);
  549. virtual DELETE_ME CBranchIterator* GetBranchIterator();
  550. virtual int ComparePrecedence(CBranchingNode* pOther) = 0;
  551. virtual int Compare(CEvalNode* pNode);
  552. virtual int SubCompare(CEvalNode* pNode) = 0;
  553. virtual HRESULT Evaluate(CObjectInfo& ObjInfo,
  554. INTERNAL CEvalNode** ppNext) = 0;
  555. virtual HRESULT CombineBranchesWith(CBranchingNode* pArg2, int nOp,
  556. CContextMetaData* pNamespace,
  557. CImplicationList& Implications,
  558. bool bDeleteThis, bool bDeleteArg2,
  559. CEvalNode** ppRes) = 0;
  560. virtual HRESULT RecordBranch(CContextMetaData* pNamespace,
  561. CImplicationList& Implications,
  562. long lBranchIndex)
  563. {return WBEM_S_NO_ERROR;}
  564. virtual HRESULT OptimizeSelf() {return WBEM_S_NO_ERROR;}
  565. HRESULT AdjustCompile(CContextMetaData* pNamespace,
  566. CImplicationList& Implications)
  567. {
  568. if (!m_pInfo)
  569. return WBEM_S_NO_ERROR;
  570. else
  571. return m_pInfo->Compile(pNamespace, Implications, NULL);
  572. }
  573. HRESULT CombineWith(CEvalNode* pArg2, int nOp,
  574. CContextMetaData* pNamespace,
  575. CImplicationList& Implications,
  576. bool bDeleteThis, bool bDeleteArg2,
  577. CEvalNode** ppRes);
  578. virtual HRESULT CombineInOrderWith(CEvalNode* pArg2,
  579. int nOp, CContextMetaData* pNamespace,
  580. CImplicationList& OrigImplications,
  581. bool bDeleteThis, bool bDeleteArg2,
  582. CEvalNode** ppRes);
  583. virtual HRESULT Optimize(CContextMetaData* pNamespace, CEvalNode** ppNew);
  584. BOOL AreAllSame(CEvalNode** apNodes, int nSize, int* pnFoundIndex);
  585. static int ComparePrecedence(CBranchingNode* pArg1, CBranchingNode* pArg2);
  586. HRESULT Project(CContextMetaData* pMeta, CImplicationList& Implications,
  587. CProjectionFilter* pFilter, EProjectionType eType,
  588. bool bDeleteThis, CEvalNode** ppNewNode);
  589. void Dump(FILE* f, int nOffset);
  590. #ifdef CHECK_TREES
  591. virtual void CheckNode(CTreeChecker *pCheck);
  592. #endif
  593. friend class CDefaultBranchIterator;
  594. };
  595. class CDefaultBranchIterator : public CBranchIterator
  596. {
  597. protected:
  598. CBranchingNode* m_pNode;
  599. int m_nIndex;
  600. public:
  601. CDefaultBranchIterator(CBranchingNode* pNode) : m_pNode(pNode), m_nIndex(-1)
  602. {}
  603. virtual INTERNAL CEvalNode* GetNode()
  604. {
  605. if(m_nIndex == -1)
  606. return m_pNode->m_pNullBranch;
  607. else
  608. return m_pNode->m_apBranches[m_nIndex];
  609. }
  610. virtual void SetNode(ACQUIRE CEvalNode* pNode)
  611. {
  612. CEvalNode* pOld;
  613. if(m_nIndex == -1)
  614. m_pNode->m_pNullBranch = pNode;
  615. else
  616. m_pNode->m_apBranches.SetAt(m_nIndex, pNode, &pOld);
  617. }
  618. virtual bool IsValid() { return m_nIndex < m_pNode->m_apBranches.GetSize();}
  619. virtual void Advance() { m_nIndex++;}
  620. virtual HRESULT RecordBranch(CContextMetaData* pMeta,
  621. CImplicationList& Implications)
  622. {
  623. return m_pNode->RecordBranch(pMeta, Implications, m_nIndex);
  624. }
  625. };
  626. // The node where a property is tested against a value. The property is
  627. // identified by a handle
  628. class CPropertyNode : public CBranchingNode
  629. {
  630. protected:
  631. long m_lPropHandle;
  632. WString m_wsPropName;
  633. public:
  634. CPropertyNode()
  635. : m_lPropHandle(-1)
  636. {}
  637. CPropertyNode(const CPropertyNode& Other, BOOL bChildren = TRUE)
  638. : CBranchingNode(Other, bChildren), m_lPropHandle(Other.m_lPropHandle),
  639. m_wsPropName(Other.m_wsPropName)
  640. {}
  641. virtual ~CPropertyNode(){}
  642. virtual int ComparePrecedence(CBranchingNode* pOther);
  643. bool SetPropertyInfo(LPCWSTR wszPropName, long lPropHandle);
  644. LPCWSTR GetPropertyName() {return m_wsPropName;}
  645. bool SetEmbeddingInfo(const CEmbeddingInfo* pInfo);
  646. virtual HRESULT SetNullTest(int nOperator);
  647. virtual HRESULT SetOperator(int nOperator);
  648. virtual HRESULT SetTest(VARIANT& v) = 0;
  649. };
  650. // An element in the array of test points
  651. template<class TPropType>
  652. struct CTestPoint
  653. {
  654. TPropType m_Test;
  655. CEvalNode* m_pLeftOf;
  656. CEvalNode* m_pAt;
  657. CTestPoint() : m_pLeftOf(NULL), m_pAt(NULL){}
  658. void Destruct() {delete m_pLeftOf; delete m_pAt;}
  659. };
  660. template<class TPropType>
  661. struct CTestPointCompare
  662. {
  663. typedef CTestPoint<TPropType> TTestPoint;
  664. inline int Compare(const TPropType& t, const TTestPoint& p) const
  665. {
  666. if(t < p.m_Test)
  667. return -1;
  668. else if(t == p.m_Test)
  669. return 0;
  670. else return 1;
  671. }
  672. inline int Compare(const TPropType& t1, const TPropType& t2) const
  673. {
  674. if(t1 < t2)
  675. return -1;
  676. else if(t1 == t2)
  677. return 0;
  678. else return 1;
  679. }
  680. inline int Compare(const TTestPoint& p1, const TTestPoint& p2) const
  681. {
  682. return Compare(p1.m_Test, p2);
  683. }
  684. inline const TPropType& Extract(const TTestPoint& p) const
  685. {
  686. return p.m_Test;
  687. }
  688. };
  689. template<class TPropType>
  690. struct CTestPointManager
  691. {
  692. typedef CTestPoint<TPropType> TTestPoint;
  693. void AddRefElement(TTestPoint& p){}
  694. void ReleaseElement(TTestPoint& p) {p.Destruct();}
  695. };
  696. template<class TPropType>
  697. class CFullCompareNode : public CPropertyNode
  698. {
  699. // protected:
  700. public: // because I can't make a template a friend of this one??
  701. typedef CSmartSortedTree<
  702. TPropType,
  703. CTestPoint<TPropType>,
  704. CTestPointManager<TPropType>,
  705. CTestPointCompare<TPropType> > TTestPointArray;
  706. typedef TTestPointArray::TIterator TTestPointIterator;
  707. typedef TTestPointArray::TConstIterator TConstTestPointIterator;
  708. TTestPointArray m_aTestPoints;
  709. CEvalNode* m_pRightMost;
  710. public:
  711. CFullCompareNode() : m_pRightMost(NULL)
  712. {}
  713. CFullCompareNode(const CFullCompareNode<TPropType>& Other,
  714. BOOL bChildren = TRUE);
  715. virtual ~CFullCompareNode();
  716. HRESULT CombineBranchesWith(CBranchingNode* pArg2, int nOp,
  717. CContextMetaData* pNamespace,
  718. CImplicationList& Implications,
  719. bool bDeleteThis, bool bDeleteArg2,
  720. CEvalNode** ppRes);
  721. HRESULT CombineInOrderWith(CEvalNode* pArg2,
  722. int nOp, CContextMetaData* pNamespace,
  723. CImplicationList& OrigImplications,
  724. bool bDeleteThis, bool bDeleteArg2,
  725. CEvalNode** ppRes);
  726. int SubCompare(CEvalNode* pOther);
  727. virtual HRESULT OptimizeSelf();
  728. virtual HRESULT SetTest(VARIANT& v);
  729. virtual DWORD ApplyPredicate(CLeafPredicate* pPred);
  730. virtual DELETE_ME CBranchIterator* GetBranchIterator()
  731. {
  732. return new CFullCompareBranchIterator<TPropType>(this);
  733. }
  734. virtual HRESULT Optimize(CContextMetaData* pNamespace, CEvalNode** ppNew);
  735. HRESULT SetNullTest(int nOperator);
  736. HRESULT SetOperator(int nOperator);
  737. protected:
  738. HRESULT CombineWithBranchesToLeft(
  739. TTestPointIterator itWalk, TTestPointIterator itLast,
  740. CEvalNode* pArg2,
  741. int nOp, CContextMetaData* pNamespace,
  742. CImplicationList& OrigImplications);
  743. HRESULT InsertLess(
  744. TTestPointIterator it,
  745. TTestPointIterator it2, TTestPointIterator& itLast,
  746. int nOp, CContextMetaData* pNamespace,
  747. CImplicationList& OrigImplications, bool bDeleteArg2);
  748. HRESULT InsertMatching(
  749. TTestPointIterator it,
  750. TTestPointIterator it2, TTestPointIterator& itLast,
  751. int nOp, CContextMetaData* pNamespace,
  752. CImplicationList& OrigImplications, bool bDeleteArg2);
  753. };
  754. template<class TPropType>
  755. class CFullCompareBranchIterator : public CBranchIterator
  756. {
  757. protected:
  758. CFullCompareNode<TPropType>* m_pNode;
  759. CFullCompareNode<TPropType>::TTestPointIterator m_it;
  760. CFullCompareNode<TPropType>::TTestPointIterator m_itEnd;
  761. bool m_bLeft;
  762. bool m_bValid;
  763. public:
  764. CFullCompareBranchIterator(CFullCompareNode<TPropType>* pNode)
  765. : m_pNode(pNode), m_it(pNode->m_aTestPoints.Begin()), m_bLeft(true),
  766. m_itEnd(pNode->m_aTestPoints.End()), m_bValid(true)
  767. {}
  768. virtual INTERNAL CEvalNode* GetNode()
  769. {
  770. if(m_it == m_itEnd)
  771. {
  772. if(m_bLeft)
  773. return m_pNode->m_pRightMost;
  774. else
  775. return m_pNode->m_pNullBranch;
  776. }
  777. else
  778. {
  779. if(m_bLeft)
  780. return m_it->m_pLeftOf;
  781. else
  782. return m_it->m_pAt;
  783. }
  784. }
  785. virtual void SetNode(ACQUIRE CEvalNode* pNode)
  786. {
  787. if(m_it == m_itEnd)
  788. {
  789. if(m_bLeft)
  790. m_pNode->m_pRightMost = pNode;
  791. else
  792. m_pNode->m_pNullBranch = pNode;
  793. }
  794. else
  795. {
  796. if(m_bLeft)
  797. m_it->m_pLeftOf = pNode;
  798. else
  799. m_it->m_pAt = pNode;
  800. }
  801. }
  802. virtual bool IsValid() { return m_bValid;}
  803. virtual void Advance()
  804. {
  805. if(m_bLeft)
  806. m_bLeft = false;
  807. else if(m_it == m_itEnd)
  808. m_bValid = false;
  809. else
  810. {
  811. m_it++;
  812. m_bLeft = true;
  813. }
  814. }
  815. virtual HRESULT RecordBranch(CContextMetaData* pMeta,
  816. CImplicationList& Implications)
  817. {
  818. return S_OK; // fullcompare nodes don't have implications
  819. }
  820. };
  821. template<class TPropType>
  822. class CScalarPropNode : public CFullCompareNode<TPropType>
  823. {
  824. public:
  825. CScalarPropNode() : CFullCompareNode<TPropType>()
  826. {}
  827. CScalarPropNode(const CScalarPropNode<TPropType>& Other,
  828. BOOL bChildren = TRUE)
  829. : CFullCompareNode<TPropType>(Other, bChildren)
  830. {}
  831. virtual ~CScalarPropNode(){}
  832. virtual long GetSubType() {return EVAL_NODE_TYPE_SCALAR; }
  833. virtual HRESULT Evaluate(CObjectInfo& ObjInfo, INTERNAL CEvalNode** ppNext);
  834. virtual CEvalNode* Clone() const
  835. {return new CScalarPropNode<TPropType>(*this);}
  836. virtual CBranchingNode* CloneSelf() const
  837. {return new CScalarPropNode<TPropType>(*this, FALSE);}
  838. virtual void Dump(FILE* f, int nOffset);
  839. };
  840. class CStringPropNode : public CFullCompareNode<CInternalString>
  841. {
  842. public:
  843. CStringPropNode()
  844. : CFullCompareNode<CInternalString>()
  845. {}
  846. CStringPropNode(const CStringPropNode& Other, BOOL bChildren = TRUE);
  847. virtual ~CStringPropNode();
  848. virtual long GetSubType() { return EVAL_NODE_TYPE_STRING; }
  849. virtual HRESULT Evaluate(CObjectInfo& ObjInfo, INTERNAL CEvalNode** ppNext);
  850. virtual CEvalNode* Clone() const {return new CStringPropNode(*this);}
  851. virtual CBranchingNode* CloneSelf() const
  852. {return new CStringPropNode(*this, FALSE);}
  853. virtual void Dump(FILE* f, int nOffset);
  854. };
  855. class CLikeStringPropNode : public CPropertyNode
  856. {
  857. protected:
  858. CLike m_Like;
  859. public:
  860. CLikeStringPropNode() {} ;
  861. CLikeStringPropNode(const CLikeStringPropNode& Other, BOOL bChildren=TRUE);
  862. virtual long GetSubType() { return EVAL_NODE_TYPE_LIKE_STRING; }
  863. virtual int ComparePrecedence(CBranchingNode* pNode);
  864. virtual int SubCompare(CEvalNode* pNode);
  865. virtual HRESULT SetTest( VARIANT& v );
  866. virtual HRESULT Evaluate( CObjectInfo& ObjInfo, CEvalNode** ppNext );
  867. virtual HRESULT CombineBranchesWith( CBranchingNode* pArg2, int nOp,
  868. CContextMetaData* pNamespace,
  869. CImplicationList& Implications,
  870. bool bDeleteThis, bool bDeleteArg2,
  871. CEvalNode** ppRes );
  872. virtual HRESULT OptimizeSelf();
  873. virtual CEvalNode* Clone() const {return new CLikeStringPropNode(*this);}
  874. virtual CBranchingNode* CloneSelf() const
  875. {return new CLikeStringPropNode(*this, FALSE);}
  876. virtual void Dump(FILE* f, int nOffset);
  877. };
  878. class CInheritanceNode : public CBranchingNode
  879. {
  880. protected:
  881. long m_lDerivationIndex;
  882. long m_lNumPoints;
  883. CCompressedString** m_apcsTestPoints;
  884. public:
  885. CInheritanceNode();
  886. CInheritanceNode(const CInheritanceNode& Other, BOOL bChildren = TRUE);
  887. virtual ~CInheritanceNode();
  888. virtual long GetSubType();
  889. virtual HRESULT Evaluate(CObjectInfo& ObjInfo, INTERNAL CEvalNode** ppNext);
  890. virtual int ComparePrecedence(CBranchingNode* pOther);
  891. virtual CEvalNode* Clone() const {return new CInheritanceNode(*this);}
  892. virtual CBranchingNode* CloneSelf() const
  893. {return new CInheritanceNode(*this, FALSE);}
  894. virtual HRESULT Compile(CContextMetaData* pNamespace,
  895. CImplicationList& Implications);
  896. virtual HRESULT CombineBranchesWith(CBranchingNode* pArg2, int nOp,
  897. CContextMetaData* pNamespace,
  898. CImplicationList& Implications,
  899. bool bDeleteThis, bool bDeleteArg2,
  900. CEvalNode** ppRes);
  901. virtual HRESULT RecordBranch(CContextMetaData* pNamespace,
  902. CImplicationList& Implications,
  903. long lBranchIndex);
  904. virtual int SubCompare(CEvalNode* pOther);
  905. virtual HRESULT OptimizeSelf();
  906. HRESULT Optimize(CContextMetaData* pNamespace, CEvalNode** ppNew);
  907. void RemoveTestPoint(int nIndex);
  908. HRESULT Project(CContextMetaData* pMeta, CImplicationList& Implications,
  909. CProjectionFilter* pFilter,
  910. EProjectionType eType, bool bDeleteThis,
  911. CEvalNode** ppNewNode);
  912. virtual void Dump(FILE* f, int nOffset);
  913. public:
  914. HRESULT AddClass(CContextMetaData* pNamespace, LPCWSTR wszClassName,
  915. CEvalNode* pDestination);
  916. HRESULT AddClass(CContextMetaData* pNamespace,
  917. LPCWSTR wszClassName, _IWmiObject* pClass,
  918. CEvalNode* pDestination);
  919. bool SetPropertyInfo(CContextMetaData* pNamespace, CPropertyName& PropName);
  920. protected:
  921. void RemoveAllTestPoints();
  922. HRESULT ComputeUsageForMerge(CInheritanceNode* pArg2,
  923. CContextMetaData* pNamespace,
  924. CImplicationList& OrigImplications,
  925. bool bDeleteThis, bool bDeleteArg2,
  926. DWORD* pdwFirstNoneCount,
  927. DWORD* pdwSecondNoneCount,
  928. bool* pbBothNonePossible);
  929. };
  930. class COrNode : public CNodeWithImplications
  931. {
  932. protected:
  933. CUniquePointerArray<CEvalNode> m_apBranches;
  934. void operator=(const COrNode& Other);
  935. public:
  936. COrNode(){}
  937. COrNode(const COrNode& Other) {*this = Other;}
  938. virtual ~COrNode(){}
  939. HRESULT AddBranch(CEvalNode* pNewBranch);
  940. virtual int GetType() {return EVAL_NODE_TYPE_OR;}
  941. virtual CEvalNode* Clone() const {return new COrNode(*this);}
  942. virtual HRESULT CombineWith(CEvalNode* pArg2, int nOp,
  943. CContextMetaData* pNamespace, CImplicationList& Implications,
  944. bool bDeleteThis, bool bDeleteArg2, CEvalNode** ppRes);
  945. virtual int Compare(CEvalNode* pOther);
  946. virtual DWORD ApplyPredicate(CLeafPredicate* pPred);
  947. virtual void Dump(FILE* f, int nOffset);
  948. virtual HRESULT Evaluate(CObjectInfo& Info, CSortedArray& trueIDs);
  949. virtual HRESULT Optimize(CContextMetaData* pNamespace, CEvalNode** ppNew);
  950. HRESULT Project(CContextMetaData* pMeta, CImplicationList& Implications,
  951. CProjectionFilter* pFilter,
  952. EProjectionType eType, bool bDeleteThis,
  953. CEvalNode** ppNewNode);
  954. protected:
  955. HRESULT CombineWithOrNode(COrNode* pArg2, int nOp,
  956. CContextMetaData* pNamespace, CImplicationList& Implications,
  957. bool bDeleteThis, bool bDeleteArg2, CEvalNode** ppRes);
  958. };
  959. class ESSCLI_POLARITY CEvalTree
  960. {
  961. protected:
  962. long m_lRef;
  963. CCritSec m_cs;
  964. CEvalNode* m_pStart;
  965. CObjectInfo m_ObjectInfo;
  966. int m_nNumValues;
  967. protected:
  968. class CRemoveIndexPredicate : public CLeafPredicate
  969. {
  970. protected:
  971. int m_nIndex;
  972. public:
  973. CRemoveIndexPredicate(int nIndex) : m_nIndex(nIndex){}
  974. DWORD operator()(CValueNode* pLeaf);
  975. };
  976. class CRemoveFailureAtIndexPredicate : public CLeafPredicate
  977. {
  978. protected:
  979. int m_nIndex;
  980. public:
  981. CRemoveFailureAtIndexPredicate(int nIndex) : m_nIndex(nIndex){}
  982. DWORD operator()(CValueNode* pLeaf);
  983. };
  984. class CRebasePredicate : public CLeafPredicate
  985. {
  986. public:
  987. CRebasePredicate(QueryID newBase) :
  988. m_newBase(newBase)
  989. {}
  990. virtual DWORD operator()(class CValueNode* pLeaf);
  991. private:
  992. QueryID m_newBase;
  993. };
  994. protected:
  995. static HRESULT InnerCombine(CEvalNode* pArg1, CEvalNode* pArg2, int nOp,
  996. CContextMetaData* pNamespace,
  997. CImplicationList& Implications,
  998. bool bDeleteArg1, bool bDeleteArg2, CEvalNode** ppRes);
  999. public:
  1000. CEvalTree();
  1001. CEvalTree(const CEvalTree& Other);
  1002. ~CEvalTree();
  1003. void operator=(const CEvalTree& Other);
  1004. bool SetBool(BOOL bVal);
  1005. bool IsFalse();
  1006. bool IsValid();
  1007. HRESULT CreateFromQuery(CContextMetaData* pNamespace,
  1008. LPCWSTR wszQuery, long lFlags, long lMaxTokens);
  1009. HRESULT CreateFromQuery(CContextMetaData* pNamespace,
  1010. QL_LEVEL_1_RPN_EXPRESSION* pQuery, long lFlags,
  1011. long lMaxTokens);
  1012. HRESULT CreateFromQuery(CContextMetaData* pNamespace,
  1013. LPCWSTR wszClassName, int nNumTokens,
  1014. QL_LEVEL_1_TOKEN* apTokens, long lFlags,
  1015. long lMaxTokens);
  1016. static HRESULT CreateFromConjunction(CContextMetaData* pNamespace,
  1017. CImplicationList& Implications,
  1018. CConjunction* pConj,
  1019. CEvalNode** ppRes);
  1020. HRESULT CreateFromDNF(CContextMetaData* pNamespace,
  1021. CImplicationList& Implications,
  1022. CDNFExpression* pDNF,
  1023. CEvalNode** ppRes);
  1024. HRESULT CombineWith(CEvalTree& Other, CContextMetaData* pNamespace,
  1025. int nOp, long lFlags = 0);
  1026. HRESULT Optimize(CContextMetaData* pNamespace);
  1027. HRESULT Evaluate(IWbemObjectAccess* pObj, CSortedArray& aTrues);
  1028. static HRESULT Evaluate(CObjectInfo& Info, CEvalNode* pStart,
  1029. CSortedArray& trueIDs);
  1030. static HRESULT Combine(CEvalNode* pArg1, CEvalNode* pArg2, int nOp,
  1031. CContextMetaData* pNamespace,
  1032. CImplicationList& Implications,
  1033. bool bDeleteArg1, bool bDeleteArg2, CEvalNode** ppRes);
  1034. static HRESULT CombineInOrder(CBranchingNode* pArg1, CEvalNode* pArg2,
  1035. int nOp,
  1036. CContextMetaData* pNamespace,
  1037. CImplicationList& Implications,
  1038. bool bDeleteArg1, bool bDeleteArg2,
  1039. CEvalNode** ppRes);
  1040. static HRESULT IsMergeAdvisable(CEvalNode* pArg1, CEvalNode* pArg2,
  1041. CImplicationList& Implications);
  1042. static HRESULT BuildFromToken(CContextMetaData* pNamespace,
  1043. CImplicationList& Implications,
  1044. QL_LEVEL_1_TOKEN& Token, CEvalNode** ppRes);
  1045. static HRESULT BuildTwoPropFromToken(CContextMetaData* pNamespace,
  1046. CImplicationList& Implications,
  1047. QL_LEVEL_1_TOKEN& Token, CEvalNode** ppRes);
  1048. static int Compare(CEvalNode* pArg1, CEvalNode* pArg2);
  1049. HRESULT RemoveIndex(int nIndex);
  1050. HRESULT UtilizeGuarantee(CEvalTree& Guaranteed,
  1051. CContextMetaData* pNamespace);
  1052. HRESULT ApplyPredicate(CLeafPredicate* pPred);
  1053. static inline bool IsNotEmpty(CEvalNode* pNode);
  1054. void Rebase(QueryID newBase);
  1055. HRESULT CreateProjection(CEvalTree& Old, CContextMetaData* pMeta,
  1056. CProjectionFilter* pFilter,
  1057. EProjectionType eType, bool bDeleteOld);
  1058. static HRESULT Project(CContextMetaData* pMeta,
  1059. CImplicationList& Implications,
  1060. CEvalNode* pOldNode, CProjectionFilter* pFilter,
  1061. EProjectionType eType, bool bDeleteOld,
  1062. CEvalNode** ppNewNode);
  1063. bool Clear();
  1064. void Dump(FILE* f);
  1065. #ifdef CHECK_TREES
  1066. void CheckNodes(CTreeChecker *pCheck);
  1067. #endif
  1068. protected:
  1069. static HRESULT CombineLeafWithBranch(CValueNode* pArg1,
  1070. CBranchingNode* pArg2, int nOp,
  1071. CContextMetaData* pNamespace,
  1072. CImplicationList& Implications,
  1073. bool bDeleteArg1, bool bDeleteArg2,
  1074. CEvalNode** ppRes);
  1075. };
  1076. class ESSCLI_POLARITY CPropertyProjectionFilter : public CProjectionFilter
  1077. {
  1078. CUniquePointerArray<CPropertyName>* m_papProperties;
  1079. public:
  1080. CPropertyProjectionFilter();
  1081. ~CPropertyProjectionFilter();
  1082. virtual bool IsInSet(CEvalNode* pNode);
  1083. bool AddProperty(const CPropertyName& Prop);
  1084. };
  1085. //#include "evaltree.inl"
  1086. HRESULT CoreGetNumParents(_IWmiObject* pClass, ULONG *plNumParents);
  1087. RELEASE_ME _IWmiObject* CoreGetEmbeddedObj(_IWmiObject* pObj, long lHandle);
  1088. INTERNAL CCompressedString* CoreGetPropertyString(_IWmiObject* pObj,
  1089. long lHandle);
  1090. INTERNAL CCompressedString* CoreGetClassInternal(_IWmiObject* pObj);
  1091. INTERNAL CCompressedString* CoreGetParentAtIndex(_IWmiObject* pObj,
  1092. long lIndex);
  1093. #endif