diff --git a/src/libebus/configfile.cpp b/src/libebus/configfile.cpp index 70e42917..0520580c 100644 --- a/src/libebus/configfile.cpp +++ b/src/libebus/configfile.cpp @@ -26,7 +26,7 @@ namespace libebus { -void ConfigFileCSV::readFile(std::istream& is, Commands& commands) +void ConfigFileCSV::parse(std::istream& is, Commands& commands) { std::string line; @@ -50,9 +50,9 @@ void ConfigFileCSV::readFile(std::istream& is, Commands& commands) }; -void ConfigFileXML::readFile(std::istream& is, Commands& commands) +void ConfigFileXML::parse(std::istream& is, Commands& commands) { - ; // ToDo: Implamantion for xml files + ; // ToDo: Implementation for xml files } @@ -91,7 +91,7 @@ Commands* ConfigCommands::getCommands() std::fstream file((*i).c_str(), std::ios::in); if(file.is_open() == true) { - m_configfile->readFile(file, *commands); + m_configfile->parse(file, *commands); file.close(); } } diff --git a/src/libebus/configfile.h b/src/libebus/configfile.h index 95d778ac..4d5183b1 100644 --- a/src/libebus/configfile.h +++ b/src/libebus/configfile.h @@ -27,55 +27,119 @@ namespace libebus { +/** available file endings / types. */ enum FileType { CSV, XML }; +/** + * @brief Base class for config files. + */ class ConfigFile { public: + /** + * @brief Destructor. + */ virtual ~ConfigFile() {} - virtual void readFile(std::istream& is, Commands& commands) = 0; + /** + * @brief read input stream and stored data into commands + * @param is open input stream for reading. + * @param commands object as datastore. + */ + virtual void parse(std::istream& is, Commands& commands) = 0; }; +/** + * @brief Class for CSV config files. + */ class ConfigFileCSV : public ConfigFile { public: + /** + * @brief Destructor. + */ ~ConfigFileCSV() {} - void readFile(std::istream& is, Commands& commands); + /** + * @brief read input stream and stored data into commands + * @param is open input stream for reading. + * @param commands object as datastore. + */ + void parse(std::istream& is, Commands& commands); }; +/** + * @brief Class for XML config files. + */ class ConfigFileXML : public ConfigFile { public: + /** + * @brief Destructor. + */ ~ConfigFileXML() {} - void readFile(std::istream& is, Commands& commands); + /** + * @brief read input stream and stored data into commands + * @param is open input stream for reading. + * @param commands object as datastore. + */ + void parse(std::istream& is, Commands& commands); }; +/** + * @brief Class for class Device. + */ class ConfigCommands { public: + /** + * @brief Set file type and add recursive files from given path. + * @param path to configuration files. + * @param Filetype to parse. + */ ConfigCommands(const std::string path, const FileType type); + + /** + * @brief Destructor. + */ ~ConfigCommands() { delete m_configfile; } + /** + * @brief setter for file type. + * @param FileType of files. + */ void setType(const FileType type); + + /** + * @brief Parse files for commands and store them into commands instance. + * @return a commands instance + */ Commands* getCommands(); private: + /** the configfile instance */ ConfigFile* m_configfile; + /** main path for configuration files */ std::string m_path; + /** valid file extension */ std::string m_extension; + /** vector of configuration files */ std::vector m_files; + /** + * @brief parse path for given file extension. + * @param path to configuration files. + * @param extension with file type. + */ void addFiles(const std::string path, const std::string extension); }; diff --git a/src/libebus/port.h b/src/libebus/port.h index 2b0dc12f..bb45ca4f 100644 --- a/src/libebus/port.h +++ b/src/libebus/port.h @@ -245,7 +245,7 @@ public: private: /** the device name */ std::string m_deviceName; - /** pointer to device instance */ + /** the device instance */ Device* m_device; /** true if device check is disabled */ bool m_noDeviceCheck;