diff --git a/src/Logging/Logging.cpp b/src/Logging/Logging.cpp index 43e38f6..e4d4851 100644 --- a/src/Logging/Logging.cpp +++ b/src/Logging/Logging.cpp @@ -41,7 +41,8 @@ int Logging::MyStreamBuf::sync ( ) if(m_mode=="Local"){ - output<< "{"<::iterator it=m_variables.begin(); it!=m_variables.end(); ++it){ @@ -400,6 +400,18 @@ void BStore::Print(bool values){ } } + return true; +} + +std::vector BStore::GetKeys(){ + std::vector keys; + for (std::map::iterator it=m_variables.begin(); it!=m_variables.end(); ++it){ + keys.push_back(it->first); + } + for (std::map::iterator it=m_ptrs.begin(); it!=m_ptrs.end(); ++it){ + if(m_variables.count(it->first)==0) keys.push_back(it->first); + } + return keys; } diff --git a/src/Store/BStore.h b/src/Store/BStore.h index 311d3b7..a9def8f 100644 --- a/src/Store/BStore.h +++ b/src/Store/BStore.h @@ -36,6 +36,7 @@ class BStore: public SerialisableObject{ bool WriteFlags(); bool Save(unsigned int entry=-1); bool GetHeader(); + std::vector GetKeys(); bool GetEntry(unsigned int entry_request); bool DeleteEntry(unsigned int entry_request); bool Close(); @@ -55,7 +56,7 @@ class BStore: public SerialisableObject{ void JsonParser(std::string input); ///< Converts a flat JSON formatted string to Store entries in the form of key value pairs. @param input The input flat JSON string. bool Print(); - void Print(bool values); ///< Prints the contents of the BoostStore. @param values If true values and keys are printed. If false just keys are printed + bool Print(bool values); ///< Prints the contents of the BoostStore. @param values If true values and keys are printed. If false just keys are printed void Delete(); ///< Deletes all entries in the BoostStore. void Remove(std::string key); ///< Removes a single entry from the BoostStore. @param key The key of the entry to remove. std::string Type(std::string key); ///< Queries the type of an entry if type checking is turned on. @param key The key of the entry to check. @return A string encoding the type info. @@ -101,12 +102,13 @@ class BStore: public SerialisableObject{ T* tmp=new T; m_ptrs[name]=new PointerWrapper(tmp); - ret*=Get(name,*tmp); } PointerWrapper* tmp=static_cast* >(m_ptrs[name]); - out=tmp->pointer; + T* internal = tmp->pointer; + ret*=Get(name,*internal); // update internally held item based on Store contents + out=internal; return ret; diff --git a/src/Store/BinaryStream.h b/src/Store/BinaryStream.h index 5af2b6c..17cfcc4 100644 --- a/src/Store/BinaryStream.h +++ b/src/Store/BinaryStream.h @@ -196,7 +196,7 @@ class BinaryStream : public SerialisableObject{ bool ret=true; unsigned int tmp=rhs.size(); ret*=(*this) << tmp; - for(int i=0; i> tmp; rhs.resize(tmp); - for(int i=0; i> rhs.at(i); } return ret; @@ -244,7 +244,7 @@ class BinaryStream : public SerialisableObject{ bool ret=true; unsigned int tmp=0; ret*=(*this) >> tmp; - for (int i=0; i> key; @@ -304,7 +304,7 @@ class BinaryStream : public SerialisableObject{ bool ret=true; unsigned int tmp=rhs.size(); ret*=(*this) << tmp; - for(int i=0; i> tmp; rhs.resize(tmp); - for(int i=0; i> rhs.at(i); } return ret; diff --git a/src/Store/Store.cpp b/src/Store/Store.cpp index e02ed24..56ec330 100644 --- a/src/Store/Store.cpp +++ b/src/Store/Store.cpp @@ -87,3 +87,13 @@ bool Store::Has(std::string key){ return (m_variables.count(key)!=0); } + +const std::map* Store::GetMap(){ + return &m_variables; +} + +bool Store::Erase(std::string key){ + if(not Has(key)) return false; + m_variables.erase(key); + return true; +} diff --git a/src/Store/Store.h b/src/Store/Store.h index aaa2171..6ad11fd 100644 --- a/src/Store/Store.h +++ b/src/Store/Store.h @@ -7,6 +7,9 @@ #include #include #include +#include +#include +#include /** * \class Store @@ -29,6 +32,8 @@ class Store{ void Print(); ///< Prints the contents of the Store. void Delete(); ///< Deletes all entries in the Store. bool Has(std::string key); ///* GetMap(); + bool Erase(std::string key); ///>out; - return !stream.fail(); + + if(stream.fail()) return false; + // the trouble here is that if we have a string "4cds" and stream it into a numeric, + // then stream.fail will be false, but only the leading numeric chars will be output. + // c++11's std::is_arithmetic(T) would be ideal here, but without c++11 we do it the long way... + if(typeid(float).name()==typeid(T).name()){ + char* pEnd; + float f1 = strtof(stream.str().c_str(), &pEnd); + if(strcmp(pEnd,"")!=0) return false; + } else if(typeid(double).name()==typeid(T).name()){ + char* pEnd; + double d1 = strtod(stream.str().c_str(), &pEnd); + if(strcmp(pEnd,"")!=0) return false; + } else if(typeid(T).name()==typeid(short int).name() || + typeid(T).name()==typeid(int).name() || + typeid(T).name()==typeid(long int).name() || +// typeid(T).name()==typeid(long long int).name() || + typeid(T).name()==typeid(unsigned char).name() || + typeid(T).name()==typeid(unsigned short int).name() || + typeid(T).name()==typeid(unsigned int).name() || + typeid(T).name()==typeid(unsigned long int).name()){ +// typeid(T).name()==typeid(unsigned long long int).name()){ + char* pEnd; + long l1 = strtol(stream.str().c_str(), &pEnd,10); + if(strcmp(pEnd,"")!=0) return false; + } + // else the data type we're streaming into is probably a string + // TODO check whether the held value is numeric and warn if so..? + return true; } else return false; diff --git a/src/Tool/Tool.h b/src/Tool/Tool.h index 14a02ad..6e55f5a 100644 --- a/src/Tool/Tool.h +++ b/src/Tool/Tool.h @@ -24,6 +24,8 @@ class Tool{ virtual bool Finalise()=0; ///< Virtual Finalise function. virtual ~Tool(){}; ///< virtual destructor. + std::string m_unique_name; + protected: Store m_variables; ///< Store used to store configuration varaibles @@ -35,13 +37,16 @@ class Tool{ template void Log(T message, int messagelevel=1, int verbosity=1){m_data->Log->Log(message,messagelevel,verbosity);} template void Log(T message, int messagelevel){m_data->Log->Log(message,messagelevel,m_verbose);} ///< Logging fuction for printouts. @param message Templated message string. @param messagelevel The verbosity level at which to show the message. Checked against internal verbosity level - + int get_ok; + std::string logmessage; + static const int v_error=0; + static const int v_warning=1; + static const int v_message=2; + static const int v_debug=3; private: - - }; #endif diff --git a/src/ToolChain/ToolChain.cpp b/src/ToolChain/ToolChain.cpp index 5dd78e0..5dc489c 100644 --- a/src/ToolChain/ToolChain.cpp +++ b/src/ToolChain/ToolChain.cpp @@ -126,6 +126,7 @@ void ToolChain::Add(std::string name,Tool *tool,std::string configfile){ m_data.Log->Log(logmessage.str(),1,m_verbose); logmessage.str(""); + tool->m_unique_name = name; m_tools.push_back(tool); m_toolnames.push_back(name); m_configfiles.push_back(configfile); @@ -179,7 +180,11 @@ int ToolChain::Initialise(){ #ifndef DEBUG } - catch(...){ + catch(std::exception& e){ + logmessage <Log( logmessage.str(),0,m_verbose); logmessage.str(""); @@ -277,7 +282,10 @@ int ToolChain::Execute(int repeates){ #ifndef DEBUG } - + catch(std::exception& e){ + logmessage<Log( logmessage.str(),0,m_verbose); @@ -357,6 +365,10 @@ int ToolChain::Finalise(){ #ifndef DEBUG } + catch(std::exception& e){ + logmessage<Log( logmessage.str(),0,m_verbose);