Browse Source
			
			
			Added DtmcParser class that parses a whole DTMC, making use of the
			
				
		Added DtmcParser class that parses a whole DTMC, making use of the
	
		
	
			
				labeling and transitions parser. Removed the parseDtmc function from IoUtility, as it became obsolete with the DtmcParser class, fitted test cases accordingly.main
				 6 changed files with 87 additions and 14 deletions
			
			
		- 
					2src/models/Dtmc.h
 - 
					33src/parser/DtmcParser.cpp
 - 
					39src/parser/DtmcParser.h
 - 
					14src/utility/IoUtility.cpp
 - 
					4src/utility/IoUtility.h
 - 
					9test/parser/ParseDtmcTest.cpp
 
@ -0,0 +1,33 @@ | 
			
		|||||
 | 
				/*
 | 
			
		||||
 | 
				 * DtmcParser.cpp | 
			
		||||
 | 
				 * | 
			
		||||
 | 
				 *  Created on: 19.12.2012 | 
			
		||||
 | 
				 *      Author: thomas | 
			
		||||
 | 
				 */ | 
			
		||||
 | 
				
 | 
			
		||||
 | 
				#include "DtmcParser.h"
 | 
			
		||||
 | 
				#include "DeterministicSparseTransitionParser.h"
 | 
			
		||||
 | 
				#include "AtomicPropositionLabelingParser.h"
 | 
			
		||||
 | 
				
 | 
			
		||||
 | 
				namespace mrmc { | 
			
		||||
 | 
				namespace parser { | 
			
		||||
 | 
				
 | 
			
		||||
 | 
				/*!
 | 
			
		||||
 | 
				 * Parses a transition file and a labeling file and produces a DTMC out of them; a pointer to the dtmc | 
			
		||||
 | 
				 * is saved in the field "dtmc" | 
			
		||||
 | 
				 * Note that the labeling file may have at most as many nodes as the transition file! | 
			
		||||
 | 
				 * | 
			
		||||
 | 
				 * @param transitionSystemFile String containing the location of the transition file (....tra) | 
			
		||||
 | 
				 * @param labelingFile String containing the location of the labeling file (....lab) | 
			
		||||
 | 
				 */ | 
			
		||||
 | 
				DtmcParser::DtmcParser(std::string const & transitionSystemFile, std::string const & labelingFile) { | 
			
		||||
 | 
					mrmc::parser::DeterministicSparseTransitionParser tp(transitionSystemFile); | 
			
		||||
 | 
					uint_fast64_t nodeCount = tp.getMatrix()->getRowCount(); | 
			
		||||
 | 
				
 | 
			
		||||
 | 
					mrmc::parser::AtomicPropositionLabelingParser lp(nodeCount, labelingFile); | 
			
		||||
 | 
				
 | 
			
		||||
 | 
					dtmc = std::shared_ptr<mrmc::models::Dtmc<double> >(new mrmc::models::Dtmc<double>(tp.getMatrix(), lp.getLabeling())); | 
			
		||||
 | 
				} | 
			
		||||
 | 
				
 | 
			
		||||
 | 
				} /* namespace parser */ | 
			
		||||
 | 
				} /* namespace mrmc */ | 
			
		||||
@ -0,0 +1,39 @@ | 
			
		|||||
 | 
				/* | 
			
		||||
 | 
				 * DtmcParser.h | 
			
		||||
 | 
				 * | 
			
		||||
 | 
				 *  Created on: 19.12.2012 | 
			
		||||
 | 
				 *      Author: thomas | 
			
		||||
 | 
				 */ | 
			
		||||
 | 
				
 | 
			
		||||
 | 
				#ifndef DTMCPARSER_H_ | 
			
		||||
 | 
				#define DTMCPARSER_H_ | 
			
		||||
 | 
				
 | 
			
		||||
 | 
				#include "Parser.h" | 
			
		||||
 | 
				#include "models/Dtmc.h" | 
			
		||||
 | 
				
 | 
			
		||||
 | 
				namespace mrmc { | 
			
		||||
 | 
				namespace parser { | 
			
		||||
 | 
				
 | 
			
		||||
 | 
				/*! | 
			
		||||
 | 
				 *	@brief Load label and transition file and return initialized dtmc object | 
			
		||||
 | 
				 * | 
			
		||||
 | 
				 *	@Note This class creates a new Dtmc object that can | 
			
		||||
 | 
				 *	be accessed via getDtmc(). However, it will not delete this object! | 
			
		||||
 | 
				 * | 
			
		||||
 | 
				 *	@Note The labeling representation in the file may use at most as much nodes as are specified in the dtmc. | 
			
		||||
 | 
				 */ | 
			
		||||
 | 
				class DtmcParser: public mrmc::parser::Parser { | 
			
		||||
 | 
				public: | 
			
		||||
 | 
					DtmcParser(std::string const & transitionSystemFile, std::string const & labelingFile); | 
			
		||||
 | 
				
 | 
			
		||||
 | 
					std::shared_ptr<mrmc::models::Dtmc<double>> getDtmc() { | 
			
		||||
 | 
						return this->dtmc; | 
			
		||||
 | 
					} | 
			
		||||
 | 
				
 | 
			
		||||
 | 
				private: | 
			
		||||
 | 
					std::shared_ptr<mrmc::models::Dtmc<double>> dtmc; | 
			
		||||
 | 
				}; | 
			
		||||
 | 
				
 | 
			
		||||
 | 
				} /* namespace parser */ | 
			
		||||
 | 
				} /* namespace mrmc */ | 
			
		||||
 | 
				#endif /* DTMCPARSER_H_ */ | 
			
		||||
						Write
						Preview
					
					
					Loading…
					
					Cancel
						Save
					
		Reference in new issue