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.

74 lines
1.4 KiB

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1998, Microsoft Corp. All rights reserved.
  4. //
  5. // FILE
  6. //
  7. // policylist.h
  8. //
  9. // SYNOPSIS
  10. //
  11. // This file defines the class PolicyList.
  12. //
  13. // MODIFICATION HISTORY
  14. //
  15. // 02/06/1998 Original version.
  16. //
  17. ///////////////////////////////////////////////////////////////////////////////
  18. #include <ias.h>
  19. #include <guard.h>
  20. #include <nap.h>
  21. #include <policylist.h>
  22. PolicyList::PolicyList()
  23. {
  24. _com_util::CheckError(FinalConstruct());
  25. }
  26. bool PolicyList::apply(IASRequest& request) const
  27. {
  28. using _com_util::CheckError;
  29. // This will acquire a scoped shared lock.
  30. Guard<PolicyList> guard(*this);
  31. for (MyList::const_iterator i = policies.begin(); i != policies.end(); ++i)
  32. {
  33. VARIANT_BOOL result;
  34. CheckError(i->first->IsTrue(request, &result));
  35. // If the condition holds, ...
  36. if (result != VARIANT_FALSE)
  37. {
  38. // ... apply the action.
  39. i->second->doAction(request);
  40. return true;
  41. }
  42. }
  43. return false;
  44. }
  45. void PolicyList::clear() throw ()
  46. {
  47. LockExclusive();
  48. policies.clear();
  49. Unlock();
  50. }
  51. void PolicyList::swap(PolicyList& pe) throw ()
  52. {
  53. // Acquire an exclusive lock on the object.
  54. LockExclusive();
  55. // Swap in the new list of policies.
  56. policies.swap(pe.policies);
  57. // Get out.
  58. Unlock();
  59. }