@@ -16,7 +16,7 @@ using namespace std;
1616
1717class FactoryOp {
1818 map<string, Program> programs;
19- OperatorPayload <uint64_t , double > messageBuffer;
19+ ProgramMessage <uint64_t , double > messageBuffer;
2020
2121 public:
2222 FactoryOp ();
@@ -54,8 +54,19 @@ class FactoryOp {
5454
5555 static Op_ptr<uint64_t , double > readOp (string const & json_string);
5656 static string writeOp (Op_ptr<uint64_t , double > const & op);
57+
5758 static Program createProgram (string const & json_string) { return Program (json_string); }
5859
60+ Bytes collect (string const & programId) {
61+ if (this ->programs .count (programId) == 0 ) throw runtime_error (" Program " + programId + " was not found" );
62+ return programs.at (programId).collect ();
63+ }
64+
65+ void restore (string const & programId, Bytes const & bytes) {
66+ if (this ->programs .count (programId) == 0 ) throw runtime_error (" Program " + programId + " was not found" );
67+ programs.at (programId).restore (bytes);
68+ }
69+
5970 string createProgram (string const & id, string const & json_program);
6071
6172 bool deleteProgram (string const & id) { return (programs.erase (id) == 1 ) ? true : false ; }
@@ -66,7 +77,7 @@ class FactoryOp {
6677 return true ;
6778 }
6879
69- OperatorPayload <uint64_t , double > processMessageBuffer (const string& apId) {
80+ ProgramMessage <uint64_t , double > processMessageBuffer (const string& apId) {
7081 if (this ->programs .count (apId) == 0 ) throw runtime_error (" Program " + apId + " was not found" );
7182 if (this ->messageBuffer .count (apId) > 0 ) {
7283 if (!this ->messageBuffer .at (apId).empty ()) {
@@ -79,7 +90,7 @@ class FactoryOp {
7990 return {};
8091 }
8192
82- OperatorPayload <uint64_t , double > processMessageBufferDebug (const string& apId) {
93+ ProgramMessage <uint64_t , double > processMessageBufferDebug (const string& apId) {
8394 if (this ->programs .count (apId) == 0 ) throw runtime_error (" Program " + apId + " was not found" );
8495 if (this ->messageBuffer .count (apId) > 0 ) {
8596 if (!this ->messageBuffer .at (apId).empty ()) {
@@ -107,15 +118,15 @@ class FactoryOp {
107118 return this ->programs .at (apId).getProgramOutputFilter ();
108119 }
109120
110- OperatorPayload <uint64_t , double > processMessageMap (string const & apId,
111- const PortPayload <uint64_t , double >& messagesMap) {
121+ ProgramMessage <uint64_t , double > processMessageMap (string const & apId,
122+ const OperatorMessage <uint64_t , double >& messagesMap) {
112123 auto it = programs.find (apId);
113124 if (it == programs.end ()) return {};
114125 return it->second .receive (messagesMap);
115126 }
116127
117- OperatorPayload <uint64_t , double > processMessageMapDebug (string const & apId,
118- const PortPayload <uint64_t , double >& messagesMap) {
128+ ProgramMessage <uint64_t , double > processMessageMapDebug (string const & apId,
129+ const OperatorMessage <uint64_t , double >& messagesMap) {
119130 auto it = programs.find (apId);
120131 if (it == programs.end ()) return {};
121132 return it->second .receiveDebug (messagesMap);
0 commit comments