Leaked source code of windows server 2003
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.

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