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.

876 lines
18 KiB

  1. // This is a part of the Microsoft Foundation Classes C++ library.
  2. // Copyright (c) 1992-2001 Microsoft Corporation, All Rights Reserved
  3. // All rights reserved.
  4. //
  5. // This source code is only intended as a supplement to the
  6. // Microsoft Foundation Classes Reference and related
  7. // electronic documentation provided with the library.
  8. // See these sources for detailed information regarding the
  9. // Microsoft Foundation Classes product.
  10. #ifndef __PROVCONT_H
  11. #define __PROVCONT_H
  12. #include <provexpt.h>
  13. template<class TYPE, class ARG_TYPE>
  14. class ProvList
  15. {
  16. private:
  17. CCriticalSection * criticalSection ;
  18. CList <TYPE, ARG_TYPE> clist ;
  19. protected:
  20. public:
  21. ProvList ( BOOL threadSafeArg = FALSE ) ;
  22. virtual ~ProvList () ;
  23. int GetCount() const;
  24. BOOL IsEmpty() const;
  25. TYPE& GetHead();
  26. TYPE GetHead() const;
  27. TYPE& GetTail();
  28. TYPE GetTail() const;
  29. TYPE RemoveHead();
  30. TYPE RemoveTail();
  31. POSITION AddHead(ARG_TYPE newElement);
  32. POSITION AddTail(ARG_TYPE newElement);
  33. void AddHead(ProvList<TYPE,ARG_TYPE>* pNewList);
  34. void AddTail(ProvList<TYPE,ARG_TYPE>* pNewList);
  35. void RemoveAll();
  36. POSITION GetHeadPosition() const;
  37. POSITION GetTailPosition() const;
  38. TYPE& GetNext(POSITION& rPosition);
  39. TYPE GetNext(POSITION& rPosition) const;
  40. TYPE& GetPrev(POSITION& rPosition);
  41. TYPE GetPrev(POSITION& rPosition) const;
  42. TYPE& GetAt(POSITION position);
  43. TYPE GetAt(POSITION position) const;
  44. void SetAt(POSITION pos, ARG_TYPE newElement);
  45. void RemoveAt(POSITION position);
  46. POSITION InsertBefore(POSITION position, ARG_TYPE newElement);
  47. POSITION InsertAfter(POSITION position, ARG_TYPE newElement);
  48. POSITION Find(ARG_TYPE searchValue, POSITION startAfter = NULL) const;
  49. POSITION FindIndex(int nIndex) const;
  50. } ;
  51. template<class TYPE, class ARG_TYPE>
  52. ProvList <TYPE,ARG_TYPE>:: ProvList ( BOOL threadSafeArg ) : criticalSection ( NULL )
  53. {
  54. if ( threadSafeArg )
  55. criticalSection = new CCriticalSection ;
  56. else
  57. criticalSection = NULL ;
  58. }
  59. template<class TYPE, class ARG_TYPE>
  60. ProvList <TYPE,ARG_TYPE> :: ~ProvList ()
  61. {
  62. if ( criticalSection )
  63. delete criticalSection ;
  64. }
  65. template<class TYPE, class ARG_TYPE>
  66. int ProvList <TYPE,ARG_TYPE> :: GetCount() const
  67. {
  68. if ( criticalSection )
  69. {
  70. criticalSection->Lock () ;
  71. int count = clist.GetCount () ;
  72. criticalSection->Unlock () ;
  73. return count ;
  74. }
  75. else
  76. {
  77. return clist.GetCount () ;
  78. }
  79. }
  80. template<class TYPE, class ARG_TYPE>
  81. BOOL ProvList <TYPE,ARG_TYPE> :: IsEmpty() const
  82. {
  83. if ( criticalSection )
  84. {
  85. criticalSection->Lock () ;
  86. BOOL isEmpty = clist.IsEmpty () ;
  87. criticalSection->Unlock () ;
  88. return isEmpty ;
  89. }
  90. else
  91. {
  92. return clist.IsEmpty () ;
  93. }
  94. }
  95. template<class TYPE, class ARG_TYPE>
  96. TYPE &ProvList <TYPE,ARG_TYPE> :: GetHead ()
  97. {
  98. if ( criticalSection )
  99. {
  100. criticalSection->Lock () ;
  101. TYPE &head = clist.GetHead () ;
  102. criticalSection->Unlock () ;
  103. return head;
  104. }
  105. else
  106. {
  107. return clist.GetHead () ;
  108. }
  109. }
  110. template<class TYPE, class ARG_TYPE>
  111. TYPE ProvList <TYPE,ARG_TYPE> :: GetHead () const
  112. {
  113. if ( criticalSection )
  114. {
  115. criticalSection->Lock () ;
  116. TYPE head = clist.GetHead () ;
  117. criticalSection->Unlock () ;
  118. return head ;
  119. }
  120. else
  121. {
  122. return clist.GetHead () ;
  123. }
  124. }
  125. template<class TYPE, class ARG_TYPE>
  126. TYPE &ProvList <TYPE,ARG_TYPE> :: GetTail()
  127. {
  128. if ( criticalSection )
  129. {
  130. criticalSection->Lock () ;
  131. TYPE &tail = clist.GetTail () ;
  132. criticalSection->Unlock () ;
  133. return tail ;
  134. }
  135. else
  136. {
  137. return clist.GetTail () ;
  138. }
  139. }
  140. template<class TYPE, class ARG_TYPE>
  141. TYPE ProvList <TYPE,ARG_TYPE> :: GetTail() const
  142. {
  143. if ( criticalSection )
  144. {
  145. criticalSection->Lock () ;
  146. TYPE tail = clist.GetTail () ;
  147. criticalSection->Unlock () ;
  148. return tail ;
  149. }
  150. else
  151. {
  152. return clist.GetTail () ;
  153. }
  154. }
  155. template<class TYPE, class ARG_TYPE>
  156. TYPE ProvList <TYPE,ARG_TYPE> :: RemoveHead()
  157. {
  158. if ( criticalSection )
  159. {
  160. criticalSection->Lock () ;
  161. TYPE head = clist.RemoveHead () ;
  162. criticalSection->Unlock () ;
  163. return head ;
  164. }
  165. else
  166. {
  167. return clist.RemoveHead () ;
  168. }
  169. }
  170. template<class TYPE, class ARG_TYPE>
  171. TYPE ProvList <TYPE,ARG_TYPE> :: RemoveTail()
  172. {
  173. if ( criticalSection )
  174. {
  175. criticalSection->Lock () ;
  176. TYPE tail = clist.RemoveTail () ;
  177. criticalSection->Unlock () ;
  178. return tail ;
  179. }
  180. else
  181. {
  182. return clist.RemoveTail () ;
  183. }
  184. }
  185. template<class TYPE, class ARG_TYPE>
  186. POSITION ProvList <TYPE,ARG_TYPE> :: AddHead(ARG_TYPE newElement)
  187. {
  188. if ( criticalSection )
  189. {
  190. criticalSection->Lock () ;
  191. POSITION position = clist.AddHead ( newElement ) ;
  192. criticalSection->Unlock () ;
  193. return position ;
  194. }
  195. else
  196. {
  197. return clist.AddHead ( newElement ) ;
  198. }
  199. }
  200. template<class TYPE, class ARG_TYPE>
  201. POSITION ProvList <TYPE,ARG_TYPE> :: AddTail(ARG_TYPE newElement)
  202. {
  203. if ( criticalSection )
  204. {
  205. criticalSection->Lock () ;
  206. POSITION position = clist.AddTail ( newElement ) ;
  207. criticalSection->Unlock () ;
  208. return position ;
  209. }
  210. else
  211. {
  212. return clist.AddTail ( newElement ) ;
  213. }
  214. }
  215. template<class TYPE, class ARG_TYPE>
  216. void ProvList <TYPE,ARG_TYPE> :: AddHead(ProvList<TYPE,ARG_TYPE> *pNewList)
  217. {
  218. if ( criticalSection )
  219. {
  220. criticalSection->Lock () ;
  221. clist.AddHead ( pNewList->clist ) ;
  222. criticalSection->Unlock () ;
  223. }
  224. else
  225. {
  226. clist.AddHead ( pNewList->clist ) ;
  227. }
  228. }
  229. template<class TYPE, class ARG_TYPE>
  230. void ProvList <TYPE,ARG_TYPE> :: AddTail(ProvList<TYPE,ARG_TYPE> *pNewList)
  231. {
  232. if ( criticalSection )
  233. {
  234. criticalSection->Lock () ;
  235. clist.AddTail ( pNewList->clist ) ;
  236. criticalSection->Unlock () ;
  237. }
  238. else
  239. {
  240. clist.AddTail ( pNewList->clist ) ;
  241. }
  242. }
  243. template<class TYPE, class ARG_TYPE>
  244. void ProvList <TYPE,ARG_TYPE> :: RemoveAll ()
  245. {
  246. if ( criticalSection )
  247. {
  248. criticalSection->Lock () ;
  249. clist.RemoveAll () ;
  250. criticalSection->Unlock () ;
  251. }
  252. else
  253. {
  254. clist.RemoveAll () ;
  255. }
  256. }
  257. template<class TYPE, class ARG_TYPE>
  258. POSITION ProvList <TYPE,ARG_TYPE> :: GetHeadPosition() const
  259. {
  260. if ( criticalSection )
  261. {
  262. criticalSection->Lock () ;
  263. POSITION position = clist.GetHeadPosition () ;
  264. criticalSection->Unlock () ;
  265. return position ;
  266. }
  267. else
  268. {
  269. return clist.GetHeadPosition () ;
  270. }
  271. }
  272. template<class TYPE, class ARG_TYPE>
  273. POSITION ProvList <TYPE,ARG_TYPE> :: GetTailPosition() const
  274. {
  275. if ( criticalSection )
  276. {
  277. criticalSection->Lock () ;
  278. POSITION position = clist.GetTailPosition () ;
  279. criticalSection->Unlock () ;
  280. return position ;
  281. }
  282. else
  283. {
  284. return clist.GetTailPosition () ;
  285. }
  286. }
  287. template<class TYPE, class ARG_TYPE>
  288. TYPE& ProvList <TYPE,ARG_TYPE> :: GetNext(POSITION& rPosition)
  289. {
  290. if ( criticalSection )
  291. {
  292. criticalSection->Lock () ;
  293. TYPE &type = clist.GetNext ( rPosition ) ;
  294. criticalSection->Unlock () ;
  295. return type ;
  296. }
  297. else
  298. {
  299. return clist.GetNext ( rPosition ) ;
  300. }
  301. }
  302. template<class TYPE, class ARG_TYPE>
  303. TYPE ProvList <TYPE,ARG_TYPE> :: GetNext(POSITION& rPosition) const
  304. {
  305. if ( criticalSection )
  306. {
  307. criticalSection->Lock () ;
  308. TYPE type = clist.GetNext ( rPosition ) ;
  309. criticalSection->Unlock () ;
  310. return type ;
  311. }
  312. else
  313. {
  314. return clist.GetNext ( rPosition ) ;
  315. }
  316. }
  317. template<class TYPE, class ARG_TYPE>
  318. TYPE& ProvList <TYPE,ARG_TYPE> :: GetPrev(POSITION& rPosition)
  319. {
  320. if ( criticalSection )
  321. {
  322. criticalSection->Lock () ;
  323. TYPE &type = clist.GetPrev ( rPosition ) ;
  324. criticalSection->Unlock () ;
  325. return type ;
  326. }
  327. else
  328. {
  329. return clist.GetPrev ( rPosition ) ;
  330. }
  331. }
  332. template<class TYPE, class ARG_TYPE>
  333. TYPE ProvList <TYPE,ARG_TYPE> :: GetPrev(POSITION& rPosition) const
  334. {
  335. if ( criticalSection )
  336. {
  337. criticalSection->Lock () ;
  338. TYPE type = clist.GetPrev ( rPosition ) ;
  339. criticalSection->Unlock () ;
  340. return type ;
  341. }
  342. else
  343. {
  344. return clist.GetPrev ( rPosition ) ;
  345. }
  346. }
  347. template<class TYPE, class ARG_TYPE>
  348. TYPE& ProvList <TYPE,ARG_TYPE> :: GetAt(POSITION rPosition)
  349. {
  350. if ( criticalSection )
  351. {
  352. criticalSection->Lock () ;
  353. TYPE &type = clist.GetAt ( rPosition ) ;
  354. criticalSection->Unlock () ;
  355. return type ;
  356. }
  357. else
  358. {
  359. return clist.GetAt ( rPosition ) ;
  360. }
  361. }
  362. template<class TYPE, class ARG_TYPE>
  363. TYPE ProvList <TYPE,ARG_TYPE> :: GetAt(POSITION rPosition) const
  364. {
  365. if ( criticalSection )
  366. {
  367. criticalSection->Lock () ;
  368. TYPE type = clist.GetAt ( rPosition ) ;
  369. criticalSection->Unlock () ;
  370. return type ;
  371. }
  372. else
  373. {
  374. return clist.GetAt ( rPosition ) ;
  375. }
  376. }
  377. template<class TYPE, class ARG_TYPE>
  378. void ProvList <TYPE,ARG_TYPE> :: SetAt(POSITION pos, ARG_TYPE newElement)
  379. {
  380. if ( criticalSection )
  381. {
  382. criticalSection->Lock () ;
  383. clist.SetAt ( pos , newElement ) ;
  384. criticalSection->Unlock () ;
  385. }
  386. else
  387. {
  388. clist.SetAt ( pos , newElement ) ;
  389. }
  390. }
  391. template<class TYPE, class ARG_TYPE>
  392. void ProvList <TYPE,ARG_TYPE> :: RemoveAt(POSITION position)
  393. {
  394. if ( criticalSection )
  395. {
  396. criticalSection->Lock () ;
  397. clist.RemoveAt ( position ) ;
  398. criticalSection->Unlock () ;
  399. }
  400. else
  401. {
  402. clist.RemoveAt ( position ) ;
  403. }
  404. }
  405. template<class TYPE, class ARG_TYPE>
  406. POSITION ProvList <TYPE,ARG_TYPE> :: InsertBefore(POSITION position, ARG_TYPE newElement)
  407. {
  408. if ( criticalSection )
  409. {
  410. criticalSection->Lock () ;
  411. POSITION position = clist.InsertBefore ( position , newElement ) ;
  412. criticalSection->Unlock () ;
  413. return position ;
  414. }
  415. else
  416. {
  417. return clist.InsertBefore ( position , newElement ) ;
  418. }
  419. }
  420. template<class TYPE, class ARG_TYPE>
  421. POSITION ProvList <TYPE,ARG_TYPE> :: InsertAfter(POSITION position, ARG_TYPE newElement)
  422. {
  423. if ( criticalSection )
  424. {
  425. criticalSection->Lock () ;
  426. POSITION position = clist.InsertAfter ( position , newElement ) ;
  427. criticalSection->Unlock () ;
  428. return position ;
  429. }
  430. else
  431. {
  432. return clist.InsertAfter ( position , newElement ) ;
  433. }
  434. }
  435. template<class TYPE, class ARG_TYPE>
  436. POSITION ProvList <TYPE,ARG_TYPE> :: Find(ARG_TYPE searchValue, POSITION startAfter ) const
  437. {
  438. if ( criticalSection )
  439. {
  440. criticalSection->Lock () ;
  441. POSITION position = clist.Find ( searchValue , startAfter ) ;
  442. criticalSection->Unlock () ;
  443. return position ;
  444. }
  445. else
  446. {
  447. return clist.Find ( searchValue , startAfter ) ;
  448. }
  449. }
  450. template<class TYPE, class ARG_TYPE>
  451. POSITION ProvList <TYPE,ARG_TYPE> :: FindIndex(int nIndex) const
  452. {
  453. if ( criticalSection )
  454. {
  455. criticalSection->Lock () ;
  456. POSITION position = clist.Find ( nIndex ) ;
  457. criticalSection->Unlock () ;
  458. return position ;
  459. }
  460. else
  461. {
  462. return clist.Find ( nIndex ) ;
  463. }
  464. }
  465. template<class TYPE, class ARG_TYPE>
  466. class ProvStack : public ProvList<TYPE,ARG_TYPE>
  467. {
  468. private:
  469. CCriticalSection * criticalSection ;
  470. protected:
  471. public:
  472. ProvStack ( BOOL threadSafeArg = FALSE ) ;
  473. virtual ~ProvStack () ;
  474. void Add ( ARG_TYPE type ) ;
  475. TYPE Get () ;
  476. TYPE Delete () ;
  477. } ;
  478. template<class TYPE, class ARG_TYPE>
  479. ProvStack <TYPE, ARG_TYPE> :: ProvStack ( BOOL threadSafeArg ) : ProvList<TYPE,ARG_TYPE> ( FALSE ) , criticalSection ( NULL )
  480. {
  481. if ( threadSafeArg )
  482. criticalSection = new CCriticalSection ;
  483. else
  484. criticalSection = NULL ;
  485. }
  486. template<class TYPE, class ARG_TYPE>
  487. ProvStack <TYPE, ARG_TYPE> :: ~ProvStack ()
  488. {
  489. if ( criticalSection )
  490. delete criticalSection ;
  491. }
  492. template<class TYPE, class ARG_TYPE>
  493. void ProvStack <TYPE, ARG_TYPE> :: Add ( ARG_TYPE type )
  494. {
  495. if ( criticalSection )
  496. {
  497. criticalSection->Lock () ;
  498. AddHead ( type ) ;
  499. criticalSection->Unlock () ;
  500. }
  501. else
  502. {
  503. AddHead ( type ) ;
  504. }
  505. }
  506. template<class TYPE, class ARG_TYPE>
  507. TYPE ProvStack <TYPE, ARG_TYPE> :: Get ()
  508. {
  509. if ( criticalSection )
  510. {
  511. criticalSection->Lock () ;
  512. TYPE type = GetHead () ;
  513. criticalSection->Unlock () ;
  514. return type ;
  515. }
  516. else
  517. {
  518. return GetHead () ;
  519. }
  520. }
  521. template<class TYPE, class ARG_TYPE>
  522. TYPE ProvStack <TYPE,ARG_TYPE> :: Delete ()
  523. {
  524. if ( criticalSection )
  525. {
  526. criticalSection->Lock () ;
  527. TYPE type = RemoveHead () ;
  528. criticalSection->Unlock () ;
  529. return type ;
  530. }
  531. else
  532. {
  533. return RemoveHead () ;
  534. }
  535. }
  536. template<class TYPE, class ARG_TYPE>
  537. class ProvQueue : public ProvList<TYPE,ARG_TYPE>
  538. {
  539. private:
  540. CCriticalSection * criticalSection ;
  541. protected:
  542. public:
  543. ProvQueue ( BOOL threadSafeArg = FALSE ) ;
  544. virtual ~ProvQueue () ;
  545. void Add ( ARG_TYPE type ) ;
  546. TYPE Get () ;
  547. TYPE Delete () ;
  548. void Rotate () ;
  549. } ;
  550. template<class TYPE, class ARG_TYPE>
  551. ProvQueue <TYPE, ARG_TYPE> :: ProvQueue ( BOOL threadSafeArg ) : ProvList<TYPE,ARG_TYPE> ( FALSE ) , criticalSection ( NULL )
  552. {
  553. if ( threadSafeArg )
  554. criticalSection = new CCriticalSection ;
  555. else
  556. criticalSection = NULL ;
  557. }
  558. template<class TYPE, class ARG_TYPE>
  559. ProvQueue <TYPE, ARG_TYPE> :: ~ProvQueue ()
  560. {
  561. if ( criticalSection )
  562. delete criticalSection ;
  563. }
  564. template<class TYPE, class ARG_TYPE>
  565. void ProvQueue <TYPE, ARG_TYPE> :: Add ( ARG_TYPE type )
  566. {
  567. if ( criticalSection )
  568. {
  569. criticalSection->Lock () ;
  570. AddTail ( type ) ;
  571. criticalSection->Unlock () ;
  572. }
  573. else
  574. {
  575. AddTail ( type ) ;
  576. }
  577. }
  578. template<class TYPE, class ARG_TYPE>
  579. TYPE ProvQueue <TYPE, ARG_TYPE> :: Get ()
  580. {
  581. if ( criticalSection )
  582. {
  583. criticalSection->Lock () ;
  584. TYPE type = GetHead () ;
  585. criticalSection->Unlock () ;
  586. return type ;
  587. }
  588. else
  589. {
  590. return GetHead () ;
  591. }
  592. }
  593. template<class TYPE, class ARG_TYPE>
  594. TYPE ProvQueue <TYPE, ARG_TYPE> :: Delete ()
  595. {
  596. if ( criticalSection )
  597. {
  598. criticalSection->Lock () ;
  599. TYPE type = RemoveHead () ;
  600. criticalSection->Unlock () ;
  601. return type ;
  602. }
  603. else
  604. {
  605. return RemoveHead () ;
  606. }
  607. }
  608. template<class TYPE, class ARG_TYPE>
  609. void ProvQueue <TYPE, ARG_TYPE> :: Rotate ()
  610. {
  611. if ( criticalSection )
  612. {
  613. criticalSection->Lock () ;
  614. TYPE type = Delete () ;
  615. Add ( type ) ;
  616. criticalSection->Unlock () ;
  617. }
  618. else
  619. {
  620. TYPE type = Delete () ;
  621. Add ( type ) ;
  622. }
  623. }
  624. template<class KEY, class ARG_KEY, class VALUE, class ARG_VALUE>
  625. class ProvMap
  626. {
  627. private:
  628. CCriticalSection * criticalSection ;
  629. CMap <KEY, ARG_KEY, VALUE, ARG_VALUE> cmap ;
  630. protected:
  631. public:
  632. ProvMap ( BOOL threadSafe = FALSE ) ;
  633. virtual ~ProvMap () ;
  634. int GetCount () const ;
  635. BOOL IsEmpty () const ;
  636. BOOL Lookup(ARG_KEY key, VALUE& rValue) const ;
  637. VALUE& operator[](ARG_KEY key) ;
  638. void SetAt(ARG_KEY key, ARG_VALUE newValue) ;
  639. BOOL RemoveKey(ARG_KEY key) ;
  640. void RemoveAll () ;
  641. POSITION GetStartPosition() const ;
  642. void GetNextAssoc(POSITION& rNextPosition, KEY& rKey, VALUE& rValue) const ;
  643. } ;
  644. template<class KEY, class ARG_KEY, class VALUE, class ARG_VALUE>
  645. ProvMap <KEY, ARG_KEY, VALUE, ARG_VALUE> :: ProvMap ( BOOL threadSafeArg ) : criticalSection ( NULL )
  646. {
  647. if ( threadSafeArg )
  648. criticalSection = new CCriticalSection ;
  649. else
  650. criticalSection = FALSE ;
  651. }
  652. template<class KEY, class ARG_KEY, class VALUE, class ARG_VALUE>
  653. ProvMap <KEY, ARG_KEY, VALUE, ARG_VALUE> :: ~ProvMap ()
  654. {
  655. if ( criticalSection )
  656. delete criticalSection ;
  657. }
  658. template<class KEY, class ARG_KEY, class VALUE, class ARG_VALUE>
  659. int ProvMap <KEY, ARG_KEY, VALUE, ARG_VALUE> :: GetCount() const
  660. {
  661. if ( criticalSection )
  662. {
  663. criticalSection->Lock () ;
  664. int count = cmap.GetCount () ;
  665. criticalSection->Unlock () ;
  666. return count ;
  667. }
  668. else
  669. {
  670. return cmap.GetCount () ;
  671. }
  672. }
  673. template<class KEY, class ARG_KEY, class VALUE, class ARG_VALUE>
  674. BOOL ProvMap <KEY, ARG_KEY, VALUE, ARG_VALUE> :: IsEmpty() const
  675. {
  676. if ( criticalSection )
  677. {
  678. criticalSection->Lock () ;
  679. BOOL isEmpty = cmap.IsEmpty () ;
  680. criticalSection->Unlock () ;
  681. return isEmpty ;
  682. }
  683. else
  684. {
  685. return cmap.IsEmpty () ;
  686. }
  687. }
  688. template<class KEY, class ARG_KEY, class VALUE, class ARG_VALUE>
  689. BOOL ProvMap <KEY, ARG_KEY, VALUE, ARG_VALUE> :: Lookup(ARG_KEY key, VALUE& rValue) const
  690. {
  691. if ( criticalSection )
  692. {
  693. criticalSection->Lock () ;
  694. BOOL lookup = cmap.Lookup ( key , rValue ) ;
  695. criticalSection->Unlock () ;
  696. return lookup ;
  697. }
  698. else
  699. {
  700. return cmap.Lookup ( key , rValue ) ;
  701. }
  702. }
  703. template<class KEY, class ARG_KEY, class VALUE, class ARG_VALUE>
  704. VALUE& ProvMap <KEY, ARG_KEY, VALUE, ARG_VALUE> :: operator[](ARG_KEY key)
  705. {
  706. if ( criticalSection )
  707. {
  708. criticalSection->Lock () ;
  709. VALUE &value = cmap.operator [] ( key ) ;
  710. criticalSection->Unlock () ;
  711. return value ;
  712. }
  713. else
  714. {
  715. return cmap.operator [] ( key ) ;
  716. }
  717. }
  718. template<class KEY, class ARG_KEY, class VALUE, class ARG_VALUE>
  719. void ProvMap <KEY, ARG_KEY, VALUE, ARG_VALUE> :: SetAt(ARG_KEY key, ARG_VALUE newValue)
  720. {
  721. if ( criticalSection )
  722. {
  723. criticalSection->Lock () ;
  724. cmap.SetAt ( key , newValue ) ;
  725. criticalSection->Unlock () ;
  726. }
  727. else
  728. {
  729. cmap.SetAt ( key , newValue ) ;
  730. }
  731. }
  732. template<class KEY, class ARG_KEY, class VALUE, class ARG_VALUE>
  733. BOOL ProvMap <KEY, ARG_KEY, VALUE, ARG_VALUE> :: RemoveKey(ARG_KEY key)
  734. {
  735. if ( criticalSection )
  736. {
  737. criticalSection->Lock () ;
  738. BOOL removeKey = cmap.RemoveKey ( key ) ;
  739. criticalSection->Unlock () ;
  740. return removeKey ;
  741. }
  742. else
  743. {
  744. return cmap.RemoveKey ( key ) ;
  745. }
  746. }
  747. template<class KEY, class ARG_KEY, class VALUE, class ARG_VALUE>
  748. void ProvMap <KEY, ARG_KEY, VALUE, ARG_VALUE> :: RemoveAll()
  749. {
  750. if ( criticalSection )
  751. {
  752. criticalSection->Lock () ;
  753. cmap.RemoveAll () ;
  754. criticalSection->Unlock () ;
  755. }
  756. else
  757. {
  758. cmap.RemoveAll () ;
  759. }
  760. }
  761. template<class KEY, class ARG_KEY, class VALUE, class ARG_VALUE>
  762. POSITION ProvMap <KEY, ARG_KEY, VALUE, ARG_VALUE> :: GetStartPosition() const
  763. {
  764. if ( criticalSection )
  765. {
  766. criticalSection->Lock () ;
  767. POSITION position = cmap.GetStartPosition () ;
  768. criticalSection->Unlock () ;
  769. return position ;
  770. }
  771. else
  772. {
  773. return cmap.GetStartPosition () ;
  774. }
  775. }
  776. template<class KEY, class ARG_KEY, class VALUE, class ARG_VALUE>
  777. void ProvMap <KEY, ARG_KEY, VALUE, ARG_VALUE>:: GetNextAssoc(POSITION& rNextPosition, KEY& rKey, VALUE& rValue) const
  778. {
  779. if ( criticalSection )
  780. {
  781. criticalSection->Lock () ;
  782. cmap.GetNextAssoc ( rNextPosition , rKey , rValue ) ;
  783. criticalSection->Unlock () ;
  784. }
  785. else
  786. {
  787. cmap.GetNextAssoc ( rNextPosition , rKey , rValue ) ;
  788. }
  789. }
  790. #endif // __PROVCONT_H