documentation for configuration classes added; readFile renamed to parse
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<std::string> 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);
|
||||
|
||||
};
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user