Console.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. Author: Juan Rada-Vilela, Ph.D.
  3. Copyright (C) 2010-2014 FuzzyLite Limited
  4. All rights reserved
  5. This file is part of fuzzylite.
  6. fuzzylite is free software: you can redistribute it and/or modify it under
  7. the terms of the GNU Lesser General Public License as published by the Free
  8. Software Foundation, either version 3 of the License, or (at your option)
  9. any later version.
  10. fuzzylite is distributed in the hope that it will be useful, but WITHOUT
  11. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12. FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
  13. for more details.
  14. You should have received a copy of the GNU Lesser General Public License
  15. along with fuzzylite. If not, see <http://www.gnu.org/licenses/>.
  16. fuzzylite™ is a trademark of FuzzyLite Limited.
  17. */
  18. #ifndef FL_CONSOLE_H
  19. #define FL_CONSOLE_H
  20. #include "fl/fuzzylite.h"
  21. #include <map>
  22. #include <string>
  23. #include <vector>
  24. namespace fl {
  25. class Engine;
  26. class FL_API Console {
  27. public:
  28. struct Option {
  29. std::string key, value, description;
  30. Option(const std::string& key = "", const std::string& value = "", const std::string& description = "") :
  31. key(key), value(value), description(description) {
  32. }
  33. };
  34. static const std::string KW_INPUT_FILE;
  35. static const std::string KW_INPUT_FORMAT;
  36. static const std::string KW_OUTPUT_FILE;
  37. static const std::string KW_OUTPUT_FORMAT;
  38. static const std::string KW_EXAMPLE;
  39. static const std::string KW_DECIMALS;
  40. static const std::string KW_DATA_INPUT;
  41. static const std::string KW_DATA_MAXIMUM;
  42. static const std::string KW_DATA_EXPORT_HEADER;
  43. static const std::string KW_DATA_EXPORT_INPUTS;
  44. static Engine* mamdani();
  45. static Engine* takagiSugeno();
  46. protected:
  47. static std::map<std::string, std::string> parse(int argc, char** argv);
  48. static void process(const std::map<std::string, std::string>& options);
  49. static void process(const std::string& input, std::ostream& writer,
  50. const std::string& inputFormat, const std::string& outputFormat,
  51. const std::map<std::string, std::string>& options);
  52. static int readCharacter();
  53. static void interactive(std::ostream& writer, Engine* engine);
  54. static std::string interactiveHelp();
  55. static void exportAllExamples(const std::string& from, const std::string& to);
  56. #if defined(FL_UNIX) && ! defined(FL_APPLE)
  57. static void benchmarkExamples(int runs);
  58. #endif
  59. public:
  60. static std::string usage();
  61. static std::vector<Option> availableOptions();
  62. static int main(int argc, char** argv);
  63. };
  64. }
  65. #endif /* FL_CONSOLE_H */