ModelVisitor.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * ModelVisitor.h - visitors for automatable models
  3. *
  4. * Copyright (c) 2019-2019 Johannes Lorenz <j.git$$$lorenz-ho.me, $$$=@>
  5. *
  6. * This file is part of LMMS - https://lmms.io
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public
  10. * License as published by the Free Software Foundation; either
  11. * version 2 of the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public
  19. * License along with this program (see COPYING); if not, write to the
  20. * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  21. * Boston, MA 02110-1301 USA.
  22. *
  23. */
  24. #ifndef MODELVISITOR_H
  25. #define MODELVISITOR_H
  26. class AutomatableModel;
  27. class BoolModel;
  28. class IntModel;
  29. class FloatModel;
  30. class ComboBoxModel;
  31. class TempoSyncKnobModel;
  32. class ModelVisitor
  33. {
  34. template<class ParentType = AutomatableModel, class ModelType>
  35. void up(ModelType& m) { visit(static_cast<ParentType&>(m)); }
  36. public:
  37. virtual void visit(AutomatableModel& ) {}
  38. virtual void visit(BoolModel& m);
  39. virtual void visit(IntModel& m);
  40. virtual void visit(FloatModel& m);
  41. virtual void visit(ComboBoxModel& m);
  42. virtual void visit(TempoSyncKnobModel& m);
  43. virtual ~ModelVisitor();
  44. };
  45. class ConstModelVisitor
  46. {
  47. template<class ParentType = AutomatableModel, class ModelType>
  48. void up(const ModelType& m) {
  49. visit(static_cast<const ParentType&>(m)); }
  50. public:
  51. virtual void visit(const AutomatableModel& ) {}
  52. virtual void visit(const BoolModel& m);
  53. virtual void visit(const IntModel& m);
  54. virtual void visit(const FloatModel& m);
  55. virtual void visit(const ComboBoxModel& m);
  56. virtual void visit(const TempoSyncKnobModel& m);
  57. virtual ~ConstModelVisitor();
  58. };
  59. #endif // MODELVISITOR_H