/src/libtomahawk/playlist/dynamic/GeneratorFactory.h

http://github.com/tomahawk-player/tomahawk · C Header · 75 lines · 31 code · 15 blank · 29 comment · 0 complexity · 0c040444abb10f39011459e6caaf87ae MD5 · raw file

  1. /* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
  2. *
  3. * Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
  4. * Copyright 2010-2011, Jeff Mitchell <jeff@tomahawk-player.org>
  5. *
  6. * Tomahawk is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * Tomahawk is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #ifndef GENERATOR_FACTORY_H
  20. #define GENERATOR_FACTORY_H
  21. #include <QHash>
  22. #include <QString>
  23. #include "playlist/dynamic/GeneratorInterface.h"
  24. #include "Typedefs.h"
  25. #include "DllMacro.h"
  26. namespace Tomahawk
  27. {
  28. /**
  29. * Generators should subclass this and have it create the custom Generator
  30. */
  31. class DLLEXPORT GeneratorFactoryInterface
  32. {
  33. public:
  34. GeneratorFactoryInterface() {}
  35. virtual ~GeneratorFactoryInterface() {}
  36. virtual GeneratorInterface* create() = 0;
  37. /**
  38. * Create a control for this generator, not tied to this generator itself. Used when loading dynamic
  39. * playlists from a dbcmd.
  40. */
  41. virtual dyncontrol_ptr createControl( const QString& controlType = QString() ) = 0;
  42. virtual QStringList typeSelectors() const = 0;
  43. };
  44. /**
  45. * Simple factory that generates Generators from string type descriptors
  46. */
  47. class DLLEXPORT GeneratorFactory
  48. {
  49. public:
  50. static geninterface_ptr create( const QString& type );
  51. // only used when loading from dbcmd
  52. static dyncontrol_ptr createControl( const QString& generatorType, const QString& controlType = QString() );
  53. static void registerFactory( const QString& type, GeneratorFactoryInterface* iface );
  54. static QStringList types();
  55. static QStringList typeSelectors( const QString& type );
  56. private:
  57. static QHash<QString, GeneratorFactoryInterface*> s_factories;
  58. };
  59. };
  60. #endif