#include "config/to-json-visitor.hpp"
#include "config/to-kvstore-visitor.hpp"
+#include "config/to-fdstore-visitor.hpp"
#include "config/from-json-visitor.hpp"
#include "config/from-kvstore-visitor.hpp"
+#include "config/from-fdstore-visitor.hpp"
#include "config/is-visitable.hpp"
#include "config/fs-utils.hpp"
* Saves the config to a KVStore.
*
* @param filename path to the KVStore db
- * @param config visitable structure to load
+ * @param config visitable structure to save
* @param configName name of the config inside the KVStore db
*/
template <class Config>
config.accept(visitor);
}
+/**
+ * Load binary data from a file/socket/pipe represented by the fd
+ *
+ * @param fd file descriptor
+ * @param config visitable structure to load
+ */
+template <class Config>
+void loadFromFD(const int fd, Config& config)
+{
+ static_assert(isVisitable<Config>::value, "Use CONFIG_REGISTER macro");
+
+ FromFDStoreVisitor visitor(fd);
+ config.accept(visitor);
+}
+
+/**
+ * Save binary data to a file/socket/pipe represented by the fd
+ *
+ * @param fd file descriptor
+ * @param config visitable structure to save
+ */
+template <class Config>
+void saveToFD(const int fd, const Config& config)
+{
+ static_assert(isVisitable<Config>::value, "Use CONFIG_REGISTER macro");
+
+ ToFDStoreVisitor visitor(fd);
+ config.accept(visitor);
+}
+
} // namespace config
#endif // CONFIG_MANAGER_HPP