Caffa  1.1.0
C++ Application Framework for Embedded Systems with introspection
cafObjectFactory.h
1 // ##################################################################################################
2 //
3 // Caffa
4 // Copyright (C) 2011- Ceetron AS (Changes up until April 2021)
5 // Copyright (C) 2021- Kontur AS (Changes from April 2021 and onwards)
6 //
7 // GNU Lesser General Public License Usage
8 // This library is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU Lesser General Public License as published by
10 // the Free Software Foundation; either version 2.1 of the License, or
11 // (at your option) any later version.
12 //
13 // This library is distributed in the hope that it will be useful, but WITHOUT ANY
14 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 // FITNESS FOR A PARTICULAR PURPOSE.
16 //
17 // See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
18 // for more details.
19 //
20 // ##################################################################################################
21 
22 #pragma once
23 
24 #include "cafObjectHandle.h"
25 
26 #include <memory>
27 #include <string>
28 
29 namespace caffa
30 {
31 //==================================================================================================
32 //
33 // Factory interface for creating CAF objects derived from ObjectHandle based on class name keyword
34 //
35 //==================================================================================================
37 {
38 public:
39  std::shared_ptr<ObjectHandle> create( const std::string_view& classKeyword ) { return doCreate( classKeyword ); }
40 
41  virtual std::string name() const = 0;
42 
43 protected:
44  ObjectFactory() {}
45  virtual ~ObjectFactory() {}
46 
47 private:
48  virtual std::shared_ptr<ObjectHandle> doCreate( const std::string_view& classKeyword ) = 0;
49 };
50 
51 } // End of namespace caffa
Definition: cafObjectFactory.h:36
Main Caffa namespace.
Definition: cafApplication.h:30