66 class GeneratedFile :
public std::enable_shared_from_this<GeneratedFile>
108 std::filesystem::path full_path =
getPath();
113 GeneratedTime mod_time = std::filesystem::last_write_time(full_path);
138 YAML::Emitter emitter;
145 std::filesystem::path file_path =
getPath();
147 std::ofstream output_stream(file_path, std::ios_base::trunc);
148 if (!output_stream.good())
153 output_stream << emitter.c_str();
154 output_stream.close();
Container for the logic for a single file to appear in MoveIt configuration package.
virtual std::string getDescription() const =0
Returns an English description of this file's purpose.
static constexpr GeneratedTime::duration TIME_MOD_TOLERANCE
GeneratedFile(const GeneratedFile &)=default
std::filesystem::path getPath() const
Returns the fully qualified path to this file.
virtual std::filesystem::path getRelativePath() const =0
Returns the path relative to the configuration package root.
virtual bool hasChanges() const =0
Returns true if this file will have changes when it is written to file.
std::filesystem::path package_path_
virtual ~GeneratedFile()=default
virtual bool write()=0
Writes the file to disk.
GeneratedFile(GeneratedFile &&)=default
const GeneratedTime & last_gen_time_
FileStatus getStatus() const
GeneratedFile(const std::filesystem::path &package_path, const GeneratedTime &last_gen_time)
bool write() override
Writes the file to disk.
virtual bool writeYaml(YAML::Emitter &emitter)=0
MOVEIT_CLASS_FORWARD(SetupConfig)
bool createParentFolders(const std::filesystem::path &file_path)
Create parent folders (recursively)
std::filesystem::file_time_type GeneratedTime
FileStatus
Status associated with each GeneratedFile.