Logo
ApraPipes 1.0
Loading...
Searching...
No Matches
FileWriterModule.h
1#pragma once
2#include <string>
3#include <unordered_map>
4#include <array>
5#include <map>
6#include <vector>
7#include "Module.h"
8#include "declarative/PropertyMacros.h"
9
10using namespace std;
11
13
15{
16public:
17 // Default constructor required for declarative pipeline support
23
24 FileWriterModuleProps(const string& _strFullFileNameWithPattern, bool _append = false) : ModuleProps()
25 {
26 strFullFileNameWithPattern = _strFullFileNameWithPattern;
27 append = _append;
28 }
29
31 bool append;
32
33 // ============================================================
34 // Property Binding for Declarative Pipeline (Legacy Binding)
35 // Maps TOML property names to existing member variables
36 // ============================================================
37 template<typename PropsT>
38 static void applyProperties(
39 PropsT& props,
40 const std::map<std::string, apra::ScalarPropertyValue>& values,
41 std::vector<std::string>& missingRequired
42 ) {
43 // Map TOML "strFullFileNameWithPattern" -> member strFullFileNameWithPattern
44 apra::applyProp(props.strFullFileNameWithPattern, "strFullFileNameWithPattern", values, true, missingRequired);
45 // Map TOML "append" -> member append
46 apra::applyProp(props.append, "append", values, false, missingRequired);
47 }
48
49 // Runtime property getter
50 apra::ScalarPropertyValue getProperty(const std::string& propName) const {
51 if (propName == "strFullFileNameWithPattern") return strFullFileNameWithPattern;
52 if (propName == "append") return append;
53 throw std::runtime_error("Unknown property: " + propName);
54 }
55
56 // Runtime property setter (all properties are static for this module)
57 bool setProperty(const std::string& propName, const apra::ScalarPropertyValue& value) {
58 throw std::runtime_error("Cannot modify static property '" + propName + "' after initialization");
59 }
60
61 // No dynamic properties
62 static std::vector<std::string> dynamicPropertyNames() {
63 return {};
64 }
65};
66
67class FileWriterModule: public Module {
68public:
70 virtual ~FileWriterModule();
71 bool init();
72 bool term();
73protected:
74 bool process(frame_container& frames);
75 bool validateInputPins();
76private:
77 boost::shared_ptr<FileSequenceDriver> mDriver;
78};
79
80
Definition FileSequenceDriver.h:10
Definition FileWriterModule.h:15
bool append
Definition FileWriterModule.h:31
FileWriterModuleProps()
Definition FileWriterModule.h:18
apra::ScalarPropertyValue getProperty(const std::string &propName) const
Definition FileWriterModule.h:50
bool setProperty(const std::string &propName, const apra::ScalarPropertyValue &value)
Definition FileWriterModule.h:57
static void applyProperties(PropsT &props, const std::map< std::string, apra::ScalarPropertyValue > &values, std::vector< std::string > &missingRequired)
Definition FileWriterModule.h:38
static std::vector< std::string > dynamicPropertyNames()
Definition FileWriterModule.h:62
string strFullFileNameWithPattern
Definition FileWriterModule.h:30
FileWriterModuleProps(const string &_strFullFileNameWithPattern, bool _append=false)
Definition FileWriterModule.h:24
Definition FileWriterModule.h:67
FileWriterModule(FileWriterModuleProps _props)
Definition FileWriterModule.cpp:8
bool validateInputPins()
Definition FileWriterModule.cpp:24
boost::shared_ptr< FileSequenceDriver > mDriver
Definition FileWriterModule.h:77
virtual ~FileWriterModule()
Definition FileWriterModule.cpp:22
bool term()
Definition FileWriterModule.cpp:56
bool process(frame_container &frames)
Definition FileWriterModule.cpp:62
bool init()
Definition FileWriterModule.cpp:43
Definition Module.h:33
Definition Module.h:151
void applyProp(T &member, const char *propName, const std::map< std::string, ScalarPropertyValue > &values, bool isRequired, std::vector< std::string > &missingRequired)
Definition PropertyMacros.h:36
std::variant< int64_t, double, bool, std::string > ScalarPropertyValue
Definition ModuleRegistry.h:30