Loading src/PreProcessor.cpp +90 −5 Original line number Diff line number Diff line Loading @@ -298,12 +298,18 @@ void PreProcessor::get_device_property() if(watchPath.empty()) throw(invalid_argument("WatchPath property is empty or not defined")); checkIfDirectoryExists(watchPath); if(destPath.empty()) throw(invalid_argument("DestPath property is empty or not defined")); checkIfDirectoryExists(destPath); if(scriptPath.empty()) throw(invalid_argument("ScriptPath property is empty or not defined")); checkIfFileExists(scriptPath); if(eventList.empty()) throw(invalid_argument("EventList property is empty or not defined")); Loading @@ -316,7 +322,6 @@ void PreProcessor::get_device_property() throw(invalid_argument(event_list_error.str())); } //Create i-notify mask from event list property const uint32_t inotifyMask = create_inotify_mask(eventList); if(sleepTime<MIN_SLEEP_TIME || sleepTime>MAX_SLEEP_TIME) Loading Loading @@ -411,7 +416,23 @@ void PreProcessor::on() DEBUG_STREAM << "PreProcessor::On() - " << device_name << endl; /*----- PROTECTED REGION ID(PreProcessor::on) ENABLED START -----*/ // Add your own code try { if(m_eventThread_sp) m_eventThread_sp->start(); } catch(std::exception& ex) { set_state(Tango::ALARM); std::stringstream error_stream; error_stream << "PreProcessor::On() " << ex.what() << std::endl; set_status(error_stream.str()); } catch(...) { set_state(Tango::ALARM); set_status("PreProcessor::On() unknown error"); } /*----- PROTECTED REGION END -----*/ // PreProcessor::on } Loading @@ -427,7 +448,23 @@ void PreProcessor::off() DEBUG_STREAM << "PreProcessor::Off() - " << device_name << endl; /*----- PROTECTED REGION ID(PreProcessor::off) ENABLED START -----*/ // Add your own code try { if(m_eventThread_sp) m_eventThread_sp->stop(); } catch(std::exception& ex) { set_state(Tango::ALARM); std::stringstream error_stream; error_stream << "PreProcessor::Off() " << ex.what() << std::endl; set_status(error_stream.str()); } catch(...) { set_state(Tango::ALARM); set_status("PreProcessor::Off() unknown error"); } /*----- PROTECTED REGION END -----*/ // PreProcessor::off } Loading @@ -452,7 +489,7 @@ uint32_t PreProcessor::create_inotify_mask(const std::vector<std::string>& event for(it=event_list.begin(); it!=event_list.end(); it++) { std::stringstream event_stream; event_stream << "FitsImporter::create_inotify_mask() "; event_stream << "PreProcessor::create_inotify_mask() "; if(it->compare("IN_ACCESS")==0) { Loading Loading @@ -521,7 +558,7 @@ uint32_t PreProcessor::create_inotify_mask(const std::vector<std::string>& event iNotifyMask += IN_ALL_EVENTS; } else throw std::invalid_argument("FitsImporter::create_inotify_mask() " throw std::invalid_argument("PreProcessor::create_inotify_mask() " "string \"" + *it + " \" is invalid inotify event"); INFO_STREAM << event_stream.str() << endl; Loading @@ -530,5 +567,53 @@ uint32_t PreProcessor::create_inotify_mask(const std::vector<std::string>& event return iNotifyMask; } //============================================================================== // PreProcessor::checkIfFileExists() //============================================================================== void PreProcessor::checkIfFileExists(std::string fileName) throw(std::invalid_argument) { DEBUG_STREAM << "PreProcessor::checkIfFileExists() - " << device_name << endl; boost::filesystem::path path(fileName); if(!boost::filesystem::exists(path)) { std::stringstream errorStream; errorStream << "File " << fileName << " not exists" << std::endl; throw std::invalid_argument(errorStream.str()); } INFO_STREAM << "PreProcessor::checkIfFileExists() " << fileName << endl; } //============================================================================== // PreProcessor::checkIfDirectoryExists() //============================================================================== void PreProcessor::checkIfDirectoryExists(std::string directoryName) throw(std::invalid_argument) { DEBUG_STREAM << "PreProcessor::checkIfFileExists() - " << device_name << endl; boost::filesystem::path path(directoryName); if(!boost::filesystem::exists(path)) { std::stringstream errorStream; errorStream << "Directory " << directoryName << " not exists" << std::endl; throw std::invalid_argument(errorStream.str()); } if(!boost::filesystem::is_directory(path)) { std::stringstream errorStream; errorStream << directoryName << " is not a directory" << std::endl; throw std::invalid_argument(errorStream.str()); } INFO_STREAM << "PreProcessor::checkIfDirectoryExists() " << directoryName << endl; } /*----- PROTECTED REGION END -----*/ // PreProcessor::namespace_ending } // namespace src/PreProcessor.h +6 −0 Original line number Diff line number Diff line Loading @@ -203,6 +203,12 @@ private: uint32_t create_inotify_mask(const std::vector<std::string>&) throw (std::invalid_argument); virtual void checkIfFileExists(std::string) throw(std::invalid_argument); virtual void checkIfDirectoryExists(std::string) throw(std::invalid_argument); /*----- PROTECTED REGION END -----*/ // PreProcessor::Additional Method prototypes }; Loading Loading
src/PreProcessor.cpp +90 −5 Original line number Diff line number Diff line Loading @@ -298,12 +298,18 @@ void PreProcessor::get_device_property() if(watchPath.empty()) throw(invalid_argument("WatchPath property is empty or not defined")); checkIfDirectoryExists(watchPath); if(destPath.empty()) throw(invalid_argument("DestPath property is empty or not defined")); checkIfDirectoryExists(destPath); if(scriptPath.empty()) throw(invalid_argument("ScriptPath property is empty or not defined")); checkIfFileExists(scriptPath); if(eventList.empty()) throw(invalid_argument("EventList property is empty or not defined")); Loading @@ -316,7 +322,6 @@ void PreProcessor::get_device_property() throw(invalid_argument(event_list_error.str())); } //Create i-notify mask from event list property const uint32_t inotifyMask = create_inotify_mask(eventList); if(sleepTime<MIN_SLEEP_TIME || sleepTime>MAX_SLEEP_TIME) Loading Loading @@ -411,7 +416,23 @@ void PreProcessor::on() DEBUG_STREAM << "PreProcessor::On() - " << device_name << endl; /*----- PROTECTED REGION ID(PreProcessor::on) ENABLED START -----*/ // Add your own code try { if(m_eventThread_sp) m_eventThread_sp->start(); } catch(std::exception& ex) { set_state(Tango::ALARM); std::stringstream error_stream; error_stream << "PreProcessor::On() " << ex.what() << std::endl; set_status(error_stream.str()); } catch(...) { set_state(Tango::ALARM); set_status("PreProcessor::On() unknown error"); } /*----- PROTECTED REGION END -----*/ // PreProcessor::on } Loading @@ -427,7 +448,23 @@ void PreProcessor::off() DEBUG_STREAM << "PreProcessor::Off() - " << device_name << endl; /*----- PROTECTED REGION ID(PreProcessor::off) ENABLED START -----*/ // Add your own code try { if(m_eventThread_sp) m_eventThread_sp->stop(); } catch(std::exception& ex) { set_state(Tango::ALARM); std::stringstream error_stream; error_stream << "PreProcessor::Off() " << ex.what() << std::endl; set_status(error_stream.str()); } catch(...) { set_state(Tango::ALARM); set_status("PreProcessor::Off() unknown error"); } /*----- PROTECTED REGION END -----*/ // PreProcessor::off } Loading @@ -452,7 +489,7 @@ uint32_t PreProcessor::create_inotify_mask(const std::vector<std::string>& event for(it=event_list.begin(); it!=event_list.end(); it++) { std::stringstream event_stream; event_stream << "FitsImporter::create_inotify_mask() "; event_stream << "PreProcessor::create_inotify_mask() "; if(it->compare("IN_ACCESS")==0) { Loading Loading @@ -521,7 +558,7 @@ uint32_t PreProcessor::create_inotify_mask(const std::vector<std::string>& event iNotifyMask += IN_ALL_EVENTS; } else throw std::invalid_argument("FitsImporter::create_inotify_mask() " throw std::invalid_argument("PreProcessor::create_inotify_mask() " "string \"" + *it + " \" is invalid inotify event"); INFO_STREAM << event_stream.str() << endl; Loading @@ -530,5 +567,53 @@ uint32_t PreProcessor::create_inotify_mask(const std::vector<std::string>& event return iNotifyMask; } //============================================================================== // PreProcessor::checkIfFileExists() //============================================================================== void PreProcessor::checkIfFileExists(std::string fileName) throw(std::invalid_argument) { DEBUG_STREAM << "PreProcessor::checkIfFileExists() - " << device_name << endl; boost::filesystem::path path(fileName); if(!boost::filesystem::exists(path)) { std::stringstream errorStream; errorStream << "File " << fileName << " not exists" << std::endl; throw std::invalid_argument(errorStream.str()); } INFO_STREAM << "PreProcessor::checkIfFileExists() " << fileName << endl; } //============================================================================== // PreProcessor::checkIfDirectoryExists() //============================================================================== void PreProcessor::checkIfDirectoryExists(std::string directoryName) throw(std::invalid_argument) { DEBUG_STREAM << "PreProcessor::checkIfFileExists() - " << device_name << endl; boost::filesystem::path path(directoryName); if(!boost::filesystem::exists(path)) { std::stringstream errorStream; errorStream << "Directory " << directoryName << " not exists" << std::endl; throw std::invalid_argument(errorStream.str()); } if(!boost::filesystem::is_directory(path)) { std::stringstream errorStream; errorStream << directoryName << " is not a directory" << std::endl; throw std::invalid_argument(errorStream.str()); } INFO_STREAM << "PreProcessor::checkIfDirectoryExists() " << directoryName << endl; } /*----- PROTECTED REGION END -----*/ // PreProcessor::namespace_ending } // namespace
src/PreProcessor.h +6 −0 Original line number Diff line number Diff line Loading @@ -203,6 +203,12 @@ private: uint32_t create_inotify_mask(const std::vector<std::string>&) throw (std::invalid_argument); virtual void checkIfFileExists(std::string) throw(std::invalid_argument); virtual void checkIfDirectoryExists(std::string) throw(std::invalid_argument); /*----- PROTECTED REGION END -----*/ // PreProcessor::Additional Method prototypes }; Loading