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.

72 lines
1.9 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 declares the class PolicyList.
  12. //
  13. // MODIFICATION HISTORY
  14. //
  15. // 02/06/1998 Original version.
  16. // 02/03/2000 Convert to use Action instead of IPolicyAction.
  17. //
  18. ///////////////////////////////////////////////////////////////////////////////
  19. #ifndef _POLICYLIST_H_
  20. #define _POLICYLIST_H_
  21. #include <nocopy.h>
  22. #include <perimeter.h>
  23. #include <vector>
  24. #include <action.h>
  25. interface ICondition;
  26. ///////////////////////////////////////////////////////////////////////////////
  27. //
  28. // CLASS
  29. //
  30. // PolicyList
  31. //
  32. // DESCRIPTION
  33. //
  34. // This class maintains and enforces a list of (condition, action) tuples.
  35. //
  36. ///////////////////////////////////////////////////////////////////////////////
  37. class PolicyList
  38. : public Perimeter, NonCopyable
  39. {
  40. public:
  41. PolicyList();
  42. // Applies the current policy list to the request. Returns true if an
  43. // action was triggered.
  44. bool apply(IASRequest& request) const;
  45. void clear() throw ();
  46. // Inserts a new (condition, action) tuple at the end of the list. This
  47. // method is not thread-safe. The user should create a temporary list
  48. // insert all the policies, then use swap() to update the real list.
  49. void insert(IConditionPtr& cond, ActionPtr& action)
  50. { policies.push_back(std::make_pair(cond, action)); }
  51. // Reserve enough space for at least N policies.
  52. void reserve(size_t N)
  53. { policies.reserve(N); }
  54. // Replaces the current policy list with the new one.
  55. void swap(PolicyList& pe) throw ();
  56. protected:
  57. typedef std::vector< std::pair<IConditionPtr, ActionPtr> > MyList;
  58. MyList policies; // The policy list.
  59. };
  60. #endif // _POLICYLIST_H_