ADTF File Library
Loading...
Searching...
No Matches
object.h
Go to the documentation of this file.
1
16
17#ifndef ADTF_FILE_FACTORY_INCLUDED
18#define ADTF_FILE_FACTORY_INCLUDED
19
20#include <adtf_file/log.h>
21
22#include <cstring>
23#include <functional>
24#include <memory>
25#include <string>
26#include <unordered_map>
27#include <utility>
28#include <vector>
29
30namespace adtf_file
31{
32
37class Object
38{
39 public:
40 virtual ~Object() = default;
41};
42
47class Objects: public std::vector<std::shared_ptr<Object>>
48{
49 public:
54
55 ~Objects();
56 Objects(const Objects&) = delete;
57 Objects(Objects&&) = delete;
58
64 template <typename OBJECT_TYPE>
65 std::vector<std::shared_ptr<OBJECT_TYPE>> getAllOfType() const
66 {
67 std::vector<std::shared_ptr<OBJECT_TYPE>> all_of_given_type;
68 for (auto& object: *this)
69 {
70 auto object_of_given_type = std::dynamic_pointer_cast<OBJECT_TYPE>(object);
71 if (object_of_given_type)
72 {
73 all_of_given_type.push_back(object_of_given_type);
74 }
75 }
76
77 return all_of_given_type;
78 }
79
86 void loadPlugin(const std::string& file_name);
87
93 void loadPlugin(const std::string& file_name, Logger* plugin_logger);
94
100 void unloadPlugin(const std::string& file_name);
101
102 private:
103 std::unordered_map<std::string, void*> _plugin_handles;
104};
105
114
121template <typename FACTORIES, typename FACTORY_TYPE>
122FACTORIES getFactories()
123{
124 FACTORIES factories;
125
126 for (auto& factory: getObjects().getAllOfType<FACTORY_TYPE>())
127 {
128 factories.add(factory);
129 }
130
131 return factories;
132}
133
138{
139 public:
144 PluginInitializer(std::function<void()> initialization_callback);
145};
146
153void loadPlugin(const std::string& file_name);
154
155}
156
157extern "C"
158{
159
160#ifdef _WIN32
167__declspec(dllimport)
168bool adtfFileIsDebugPlugin();
169#endif
170
176#ifdef _WIN32
177__declspec(dllimport)
178#endif
179const char* adtfFileGetVersion();
180
187#ifdef _WIN32
188__declspec(dllimport)
189#endif
191
192}
193
194#endif // _ADTF_FILE_ADTF_FILE_READER_INCLUDED_
Abstract sink for log messages produced by the adtf_file library.
Definition log.h:67
base interface class for all available objects of the ADTF File Library that can be added to the obje...
Definition object.h:38
container for objects. this object container can be retrieved as objects singleton of the library via...
Definition object.h:48
std::vector< std::shared_ptr< OBJECT_TYPE > > getAllOfType() const
Get the All Of Type of type OBJECT_TYPE.
Definition object.h:65
void unloadPlugin(const std::string &file_name)
Unload a plugin.
void loadPlugin(const std::string &file_name)
Load a plugin.
void loadPlugin(const std::string &file_name, Logger *plugin_logger)
Load a plugin.
PluginInitializer(std::function< void()> initialization_callback)
CTOR.
namespace for ADTF File library
Definition adtf2_adtf_core_media_sample_deserializer.h:25
FACTORIES getFactories()
Get the Factories from the objects singleton of the library.
Definition object.h:122
void loadPlugin(const std::string &file_name)
Loads a ADTF File Library plugin.
Objects & getObjects()
Get the objects singleton of the library.
const char * adtfFileGetVersion()
retrieves the ADTF File Library plugin version
void adtfFileSetObjects2(adtf_file::Objects &objects)
sets the objects singleton of the calling application to the plugin