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.

77 lines
2.9 KiB

  1. //==============================================================================
  2. //
  3. // Copyright (c) 2015-
  4. // Authors:
  5. // * Joachim Klein <klein@tcs.inf.tu-dresden.de>
  6. // * David Mueller <david.mueller@tcs.inf.tu-dresden.de>
  7. //
  8. //------------------------------------------------------------------------------
  9. //
  10. // This file is part of the cpphoafparser library,
  11. // http://automata.tools/hoa/cpphoafparser/
  12. //
  13. // The cpphoafparser library is free software; you can redistribute it and/or
  14. // modify it under the terms of the GNU Lesser General Public
  15. // License as published by the Free Software Foundation; either
  16. // version 2.1 of the License, or (at your option) any later version.
  17. //
  18. // The cpphoafparser library is distributed in the hope that it will be useful,
  19. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  21. // Lesser General Public License for more details.
  22. //
  23. // You should have received a copy of the GNU Lesser General Public
  24. // License along with this library; if not, write to the Free Software
  25. // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  26. //
  27. //==============================================================================
  28. #ifndef CPPHOAFPARSER_ACCEPTANCEREPOSITORY_H
  29. #define CPPHOAFPARSER_ACCEPTANCEREPOSITORY_H
  30. #include <stdexcept>
  31. #include <memory>
  32. #include "cpphoafparser/consumer/hoa_consumer.hh"
  33. namespace cpphoafparser {
  34. /**
  35. * Virtual base class defining the interface to a repository of known acceptance names.
  36. * This can be used to construct the canonical acceptance expression for a given acc-name header,
  37. * i.e., the acceptance name (with the extra parameters) for known acceptance names.
  38. */
  39. class AcceptanceRepository
  40. {
  41. public:
  42. /** A shared_ptr wrapping an AcceptanceRepository */
  43. typedef std::shared_ptr<AcceptanceRepository> ptr;
  44. /** An acceptance condition expression */
  45. typedef HOAConsumer::acceptance_expr acceptance_expr;
  46. /** This exception is thrown if the extra arguments of an acc-name are malformed */
  47. class IllegalArgumentException : public std::runtime_error {
  48. public:
  49. /** Constructor */
  50. IllegalArgumentException(const std::string& s) : std::runtime_error(s) {}
  51. };
  52. /** Destructor */
  53. virtual ~AcceptanceRepository() {}
  54. /**
  55. * For a given acc-name header, construct the corresponding canonical acceptance expression.
  56. * If the acc-name is not known, returns an empty pointer.
  57. *
  58. * @param accName the acceptance name, as passed in an acc-name header
  59. * @param extraInfo extra info, as passed in an acc-name header
  60. * @return the canonical acceptance expression for this name, empty pointer if not known
  61. * @throws IllegalParameterException if the acceptance name is known, but there is an error with the extraInfo
  62. */
  63. virtual acceptance_expr::ptr getCanonicalAcceptanceExpression(const std::string& accName, const std::vector<IntOrString>& extraInfo) = 0;
  64. };
  65. }
  66. #endif