RuleBlock.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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_RULEBLOCK_H
  19. #define FL_RULEBLOCK_H
  20. #include "fl/fuzzylite.h"
  21. #include <string>
  22. #include <vector>
  23. namespace fl {
  24. class Engine;
  25. class Rule;
  26. class TNorm;
  27. class SNorm;
  28. class FL_API RuleBlock {
  29. private:
  30. void copyFrom(const RuleBlock& source);
  31. protected:
  32. std::vector<Rule*> _rules;
  33. std::string _name;
  34. FL_unique_ptr<TNorm> _conjunction;
  35. FL_unique_ptr<SNorm> _disjunction;
  36. FL_unique_ptr<TNorm> _activation;
  37. bool _enabled;
  38. public:
  39. RuleBlock(const std::string& name = "");
  40. RuleBlock(const RuleBlock& other);
  41. RuleBlock& operator=(const RuleBlock& other);
  42. virtual ~RuleBlock();
  43. FL_DEFAULT_MOVE(RuleBlock)
  44. virtual void activate();
  45. virtual void setName(std::string name);
  46. virtual std::string getName() const;
  47. virtual void setConjunction(TNorm* conjunction);
  48. virtual TNorm* getConjunction() const;
  49. virtual void setDisjunction(SNorm* disjunction);
  50. virtual SNorm* getDisjunction() const;
  51. virtual void setActivation(TNorm* activation);
  52. virtual TNorm* getActivation() const;
  53. virtual void setEnabled(bool enabled);
  54. virtual bool isEnabled() const;
  55. virtual void unloadRules() const;
  56. virtual void loadRules(const Engine* engine);
  57. virtual void reloadRules(const Engine* engine);
  58. virtual std::string toString() const;
  59. /**
  60. * Operations for iterable datatype _rules
  61. */
  62. virtual void addRule(Rule* rule);
  63. virtual void insertRule(Rule* rule, int index);
  64. virtual Rule* getRule(int index) const;
  65. virtual Rule* removeRule(int index);
  66. virtual int numberOfRules() const;
  67. virtual void setRules(const std::vector<Rule*>& rules);
  68. virtual const std::vector<Rule*>& rules() const;
  69. virtual std::vector<Rule*>& rules();
  70. };
  71. }
  72. #endif /* RULEBLOCK_H */