libAlgAudio  v1.99-440-g08538e5-dirty
The development library for AlgAudio framework.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ModuleFactory.hpp
Go to the documentation of this file.
1 #ifndef MODULEFACTORY_HPP
2 #define MODULEFACTORY_HPP
3 /*
4 This file is part of AlgAudio.
5 
6 AlgAudio, Copyright (C) 2015 CeTA - Audiovisual Technology Center
7 
8 AlgAudio is free software: you can redistribute it and/or modify
9 it under the terms of the GNU Lesser General Public License as
10 published by the Free Software Foundation, either version 3 of the
11 License, or (at your option) any later version.
12 
13 AlgAudio 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
16 GNU Lesser General Public License for more details.
17 
18 You should have received a copy of the GNU Lesser General Public License
19 along with AlgAudio. If not, see <http://www.gnu.org/licenses/>.
20 */
21 
22 #include <memory>
23 #include <set>
24 #include "Module.hpp"
25 #include "ModuleTemplate.hpp"
26 #include "LateReturn.hpp"
27 
28 namespace AlgAudio{
29 
30 namespace Exceptions{
32  ModuleInstanceCreationFailed(std::string t, std::string id_) : Exception(t), id(id_) {};
33  std::string id;
34 };
35 } // namespace Exceptions
36 
37 class Canvas;
38 
42 private:
43  ModuleFactory() = delete; // static class
44  static std::set<std::shared_ptr<Module>> instances;
45 public:
52  static LateReturn<std::shared_ptr<Module>> CreateNewInstance(std::shared_ptr<ModuleTemplate> templ, std::shared_ptr<Canvas> parent);
59  static LateReturn<std::shared_ptr<Module>> CreateNewInstance(std::string id, std::shared_ptr<Canvas> parent);
60  static LateReturn<> DestroyInstance(std::shared_ptr<Module>);
61  static std::shared_ptr<ModuleTemplate> GetTemplateByID(std::string);
62 };
63 
64 } // namnespace AlgAudio
65 #endif // MODULEFACTORY_HPP
static LateReturn< std::shared_ptr< Module > > CreateNewInstance(std::shared_ptr< ModuleTemplate > templ, std::shared_ptr< Canvas > parent)
ModuleInstanceCreationFailed(std::string t, std::string id_)
Definition: ModuleFactory.hpp:32
Definition: Alertable.hpp:26
std::string id
Definition: ModuleFactory.hpp:32
static LateReturn DestroyInstance(std::shared_ptr< Module >)
Definition: LateReturn.hpp:35
Definition: Exception.hpp:29
Definition: ModuleFactory.hpp:41
static std::shared_ptr< ModuleTemplate > GetTemplateByID(std::string)