35#ifndef _CDIXMLGENERATOR_HXX_
36#define _CDIXMLGENERATOR_HXX_
64 template <
class ConfigDef>
66 const ConfigDef &config,
const char *filename,
70 ConfigDef cfg(config.offset());
71 cfg.config_renderer().render_cdi(&cdi_string);
75 bool need_write =
false;
76 LOG(
INFO,
"[CDI] Checking %s...", filename);
77 FILE *ff = fopen(filename,
"rb");
80 LOG(
INFO,
"[CDI] File %s does not exist", filename);
87 if (current_str != cdi_string)
89 LOG(
INFO,
"[CDI] File %s is not up-to-date", filename);
94 LOG(
INFO,
"[CDI] File %s appears up-to-date (len %u vs %u)",
95 filename, current_str.size(), cdi_string.size());
100 LOG(
INFO,
"[CDI] Updating %s (len %u)", filename,
107 LOG(
INFO,
"[CDI] Registering CDI with stack...");
109 auto *v =
new vector<uint16_t>();
110 cfg.handle_events([v](
unsigned o) { v->push_back(o); });
112 stack->set_event_offsets(v);
119 stack->memory_config_handler()->registry()->insert(
string read_file_to_string(const string &filename)
Opens a file, reads the entire contents, stores it in a c++ std::string and returns this string.
void write_string_to_file(const string &filename, const string &data)
Opens (or creates) a file, truncates it and overwrites the contents with what is given in a string.
Standalone utility class for generating the XML representation of the node configuration structure.
static bool create_config_descriptor_xml(const ConfigDef &config, const char *filename, openlcb::SimpleStackBase *stack=nullptr)
Creates the XML representation of the configuration structure and saves it to a file on the filesyste...
Abstract base class for the address spaces exported via the Memory Config Protocol.
Memory space implementation that exports the contents of a file as a memory space.
#define LOG(level, message...)
Conditionally write a message to the logging output.
static const int INFO
Loglevel that is printed by default, reporting some status information.