logic_check.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. // Copyright (C) 2011 Internet Systems Consortium, Inc. ("ISC")
  2. //
  3. // Permission to use, copy, modify, and/or distribute this software for any
  4. // purpose with or without fee is hereby granted, provided that the above
  5. // copyright notice and this permission notice appear in all copies.
  6. //
  7. // THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
  8. // REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  9. // AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
  10. // INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  11. // LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  12. // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  13. // PERFORMANCE OF THIS SOFTWARE.
  14. #ifndef ACL_LOGIC_CHECK_H
  15. #define ACL_LOGIC_CHECK_H
  16. #include "check.h"
  17. #include "loader.h"
  18. namespace isc {
  19. namespace acl {
  20. class AnyOfSpec {
  21. public:
  22. static bool start() { return (false); }
  23. static bool terminate(const bool another) {
  24. return (another);
  25. }
  26. };
  27. class AllOfSpec {
  28. public:
  29. static bool start() { return (true); }
  30. static bool terminate(const bool another) {
  31. return (!another);
  32. }
  33. };
  34. template<typename Mode, typename Context>
  35. class LogicOperator : public CompoundCheck<Context> {
  36. public:
  37. void addSubexpression(boost::shared_ptr<Check<Context> > expr);
  38. virtual typename CompoundCheck<Context>::Checks getSubexpressions() const;
  39. virtual bool matches(const Context& context) const;
  40. };
  41. template<typename Mode, typename Context, typename Action = BasicAction>
  42. class LogicCreator : public Loader<Context, Action>::CheckCreator {
  43. public:
  44. LogicCreator(const std::string& name);
  45. virtual std::vector<std::string> names() const;
  46. virtual boost::shared_ptr<Check<Context> > create(const std::string&,
  47. data::ConstElementPtr
  48. definition,
  49. const Loader<Context,
  50. Action>& loader);
  51. virtual bool allowListAbbreviation() const { return (false); }
  52. };
  53. }
  54. }
  55. #endif