#include <creaImageIOSettings.h>
Public Member Functions | |
| Settings (const std::string i_path) | |
| ~Settings () | |
| const std::string | getValue (const std::string i_key) |
| void | addDB (const std::string &i_path) |
| void | removeDB (const std::string &i_path) |
| void | updateSetting (const std::string &key, const std::string &val) |
| void | writeSettingsFile () |
Private Member Functions | |
| void | readSettings (std::vector< std::string > &i_Keys, const std::string &i_file) |
| void | createFile () |
| void | writeSettings (std::ofstream &o_filebuf) |
Private Attributes | |
| std::map< std::string, std::string > | m_SettingsMap |
| std::string | m_SettingsFileName |
Definition at line 16 of file creaImageIOSettings.h.
| creaImageIO::Settings::Settings | ( | const std::string | i_path | ) |
Definition at line 19 of file creaImageIOSettings.cpp.
References createFile(), m_SettingsFileName, readSettings(), SETTINGS_COPY_PATH, SETTINGS_DBPATH, SETTINGS_OUTPUT_ASK, SETTINGS_OUTPUT_DIM, SETTINGS_REMOVE_PATIENT_DISPLAY, SETTINGS_SYNC_EVENT, and SETTINGS_SYNC_FREQ.
{
//need to position path in user directory first.
m_SettingsFileName = i_path + "\\.creaImageIO\\share\\creaImageIO\\app.config";
//Test if Settings File exist
if(!boost::filesystem::exists(m_SettingsFileName) )
{
createFile();
}
std::ifstream ifs(m_SettingsFileName.c_str());
std::string line;
std::string sets;
if (ifs.is_open())
{
while (! ifs.eof() )
{
getline(ifs,line);
sets += line;
}
ifs.close();
}
std::vector<std::string> Keys;
Keys.push_back(SETTINGS_SYNC_EVENT);
Keys.push_back(SETTINGS_DBPATH);
Keys.push_back(SETTINGS_SYNC_FREQ);
Keys.push_back(SETTINGS_COPY_PATH);
Keys.push_back(SETTINGS_REMOVE_PATIENT_DISPLAY);
Keys.push_back(SETTINGS_OUTPUT_ASK);
Keys.push_back(SETTINGS_OUTPUT_DIM);
readSettings(Keys, sets);
}

| creaImageIO::Settings::~Settings | ( | ) |
Definition at line 52 of file creaImageIOSettings.cpp.
{
}
| void creaImageIO::Settings::addDB | ( | const std::string & | i_path | ) |
Definition at line 112 of file creaImageIOSettings.cpp.
References m_SettingsMap, and SETTINGS_DBPATH.
Referenced by creaImageIO::Gimmick::addDB().
{
if(m_SettingsMap[SETTINGS_DBPATH].find(i_path) == std::string::npos)
{
m_SettingsMap[SETTINGS_DBPATH] += i_path + ";";
}
}

| void creaImageIO::Settings::createFile | ( | ) | [private] |
Definition at line 63 of file creaImageIOSettings.cpp.
References m_SettingsFileName, m_SettingsMap, and writeSettingsFile().
Referenced by Settings().
{
m_SettingsMap[SETTINGS_SYNC_FREQ] = "12";
m_SettingsMap[SETTINGS_SYNC_EVENT] = "end";
m_SettingsMap[SETTINGS_DBPATH] = "";
m_SettingsMap[SETTINGS_DICOM_LIBRARY] = "gdcm";
m_SettingsMap[SETTINGS_COPY_PATH] = m_SettingsFileName.substr(0,m_SettingsFileName.find_last_of('\\')+1)+"Copied files";
m_SettingsMap[SETTINGS_REMOVE_PATIENT_DISPLAY] = "0";
m_SettingsMap[SETTINGS_OUTPUT_ASK] ="true";
m_SettingsMap[SETTINGS_OUTPUT_DIM] = "1";
writeSettingsFile();
}


| const std::string creaImageIO::Settings::getValue | ( | const std::string | i_key | ) | [inline] |
Definition at line 22 of file creaImageIOSettings.h.
References m_SettingsMap.
Referenced by creaImageIO::Gimmick::addDBSettings(), creaImageIO::Gimmick::CopyFiles(), and creaImageIO::Gimmick::GetSetting().
{return m_SettingsMap[i_key];}

| void creaImageIO::Settings::readSettings | ( | std::vector< std::string > & | i_Keys, | |
| const std::string & | i_file | |||
| ) | [private] |
Definition at line 82 of file creaImageIOSettings.cpp.
References m_SettingsMap.
Referenced by Settings().
{
std::vector<std::string>::iterator it_key = i_Keys.begin();
for(; it_key< i_Keys.end(); ++it_key)
{
size_t fpos = i_file.find(it_key->c_str());
size_t lpos = i_file.rfind(it_key->c_str());
if(fpos != std::string::npos && lpos != std::string::npos)
{
m_SettingsMap[it_key->c_str()] = i_file.substr(fpos + it_key->size(),lpos-fpos - it_key->size());
}
}
}

| void creaImageIO::Settings::removeDB | ( | const std::string & | i_path | ) |
Definition at line 126 of file creaImageIOSettings.cpp.
References m_SettingsMap, and SETTINGS_DBPATH.
{
boost::algorithm::replace_all(m_SettingsMap[SETTINGS_DBPATH],i_path + ";","");
}
| void creaImageIO::Settings::updateSetting | ( | const std::string & | key, | |
| const std::string & | val | |||
| ) |
Definition at line 102 of file creaImageIOSettings.cpp.
References m_SettingsMap.
Referenced by creaImageIO::Gimmick::UpdateSetting().
{
m_SettingsMap[key.c_str()] = val;
}

| void creaImageIO::Settings::writeSettings | ( | std::ofstream & | o_filebuf | ) | [private] |
Definition at line 137 of file creaImageIOSettings.cpp.
References m_SettingsMap.
Referenced by writeSettingsFile().
{
std::map<std::string, std::string>::iterator it_map = m_SettingsMap.begin();
std::stringstream st;
for(; it_map != m_SettingsMap.end(); ++it_map)
{
o_file << it_map->first.c_str();
o_file << it_map->second.c_str();
o_file << it_map->first.c_str();
o_file << std::endl;
}
}

| void creaImageIO::Settings::writeSettingsFile | ( | ) |
Definition at line 155 of file creaImageIOSettings.cpp.
References m_SettingsFileName, and writeSettings().
Referenced by createFile(), creaImageIO::Gimmick::UpdateSetting(), and creaImageIO::Gimmick::~Gimmick().
{
std::ofstream ofs(m_SettingsFileName.c_str());
ofs.clear();
writeSettings(ofs);
ofs.close();
}


std::string creaImageIO::Settings::m_SettingsFileName [private] |
Definition at line 42 of file creaImageIOSettings.h.
Referenced by createFile(), Settings(), and writeSettingsFile().
std::map<std::string, std::string> creaImageIO::Settings::m_SettingsMap [private] |
Definition at line 35 of file creaImageIOSettings.h.
Referenced by addDB(), createFile(), getValue(), readSettings(), removeDB(), updateSetting(), and writeSettings().
1.7.1