Browse Source
			
			
			Introduced a new Object called InternalOptionMemento to handle required settings for tests which auto-reset after the test is done
			
				
		Introduced a new Object called InternalOptionMemento to handle required settings for tests which auto-reset after the test is done
	
		
	
			
				Refactored many constants to be of type ull where required
Edited all tests that used the set() function of the Settings to make use of the new InternalOptionMemento
Former-commit-id: a400a36f69
			
			
				main
			
			
		
				 13 changed files with 210 additions and 103 deletions
			
			
		- 
					70src/settings/InternalOptionMemento.h
- 
					4src/settings/Option.h
- 
					32src/settings/Settings.h
- 
					9test/functional/modelchecker/EigenDtmcPrctlModelCheckerTest.cpp
- 
					30test/functional/modelchecker/GmmxxDtmcPrctlModelCheckerTest.cpp
- 
					16test/functional/modelchecker/GmmxxMdpPrctlModelCheckerTest.cpp
- 
					8test/functional/modelchecker/SparseMdpPrctlModelCheckerTest.cpp
- 
					14test/functional/parser/ParsePrismTest.cpp
- 
					11test/functional/storm-functional-tests.cpp
- 
					48test/performance/graph/GraphTest.cpp
- 
					17test/performance/modelchecker/GmmxxDtmcPrctModelCheckerTest.cpp
- 
					30test/performance/modelchecker/GmmxxMdpPrctModelCheckerTest.cpp
- 
					24test/performance/modelchecker/SparseMdpPrctlModelCheckerTest.cpp
| @ -0,0 +1,70 @@ | |||
| #ifndef STORM_SETTINGS_INTERNALOPTIONMEMENTO_H_ | |||
| #define STORM_SETTINGS_INTERNALOPTIONMEMENTO_H_ | |||
| 
 | |||
| #include "src/settings/Settings.h" | |||
| #include "log4cplus/logger.h" | |||
| #include "log4cplus/loggingmacros.h" | |||
| 
 | |||
| extern log4cplus::Logger logger; | |||
| 
 | |||
| namespace storm { | |||
| namespace settings { | |||
| 
 | |||
| 	/*! | |||
| 	 *	@brief	THIS CLASS IS FOR INTERNAL USE IN THE TESTS ONLY | |||
| 	 * | |||
| 	 * | |||
| 	 *	If an option is required to be set when executing a test | |||
| 	 *	the test may instantiate an Object of this class while the | |||
| 	 *	test itself is executed. | |||
| 	 * | |||
| 	 *	This class ensures that the option has the requested value | |||
| 	 *	and resets it to its previous value as soon as its destructor | |||
| 	 *	is called. | |||
| 	 */ | |||
| 	class InternalOptionMemento { | |||
| 		public: | |||
| 			/*! | |||
| 			 *	@brief The constructor. | |||
| 			 * | |||
| 			 *	@param  | |||
| 			 */ | |||
| 			InternalOptionMemento(std::string const& longOptionName, bool requiredHasBeenSetState): instance(storm::settings::Settings::getInstance()), optionName(longOptionName), stateRequired(requiredHasBeenSetState) { | |||
| 				this->stateBefore = instance->isSet(optionName); | |||
| 				if (stateRequired) { | |||
| 					instance->set(optionName); | |||
| 				} else { | |||
| 					instance->unset(optionName); | |||
| 				} | |||
| 			} | |||
| 			 | |||
| 			/*! | |||
| 			 *	@brief	The destructor. | |||
| 			 * | |||
| 			 *	Resets the Options state to its previous state | |||
| 			 */ | |||
| 			virtual ~InternalOptionMemento() { | |||
| 				// Reset the state of the Option | |||
| 				if (stateBefore) { | |||
| 					instance->set(optionName); | |||
| 				} else { | |||
| 					instance->unset(optionName); | |||
| 				} | |||
| 				this->instance = nullptr; | |||
| 			} | |||
| 
 | |||
| 
 | |||
| 			 | |||
| 		private: | |||
| 			storm::settings::Settings* instance; | |||
| 			std::string const optionName; | |||
| 			bool stateBefore; | |||
| 			bool stateRequired; | |||
| 
 | |||
| 			InternalOptionMemento(InternalOptionMemento& other) {} | |||
| 	}; | |||
| 
 | |||
| } // namespace settings | |||
| } // namespace storm | |||
| 
 | |||
| #endif // STORM_SETTINGS_INTERNALOPTIONMEMENTO_H_ | |||
						Write
						Preview
					
					
					Loading…
					
					Cancel
						Save
					
		Reference in new issue