Browse Source

improved handling of capacities by switching to boost::optional

tempestpy_adaptions
Sebastian Junges 7 years ago
parent
commit
61f31fb919
  1. 2
      src/storm-gspn/parser/GreatSpnEditorProjectParser.cpp
  2. 5
      src/storm-gspn/parser/PnmlParser.cpp
  3. 2
      src/storm-gspn/storage/gspn/GspnBuilder.cpp
  4. 2
      src/storm-gspn/storage/gspn/GspnBuilder.h
  5. 2
      src/storm-gspn/storage/gspn/Place.cpp
  6. 4
      src/storm-gspn/storage/gspn/Place.h

2
src/storm-gspn/parser/GreatSpnEditorProjectParser.cpp

@ -212,7 +212,7 @@ namespace storm {
STORM_PRINT_AND_LOG("unknown child (node=" + storm::adapters::XMLtoString(node->getNodeName()) + "): " + name + "\n"); STORM_PRINT_AND_LOG("unknown child (node=" + storm::adapters::XMLtoString(node->getNodeName()) + "): " + name + "\n");
} }
} }
builder.addPlace(-1, initialTokens, placeName);
builder.addPlace(boost::none, initialTokens, placeName);
} }
bool ignoreTransitionAttribute(std::string const& name) { bool ignoreTransitionAttribute(std::string const& name) {

5
src/storm-gspn/parser/PnmlParser.cpp

@ -104,7 +104,7 @@ namespace storm {
std::string placeName; std::string placeName;
// the first entry is false if the corresponding information was not found in the pnml file // the first entry is false if the corresponding information was not found in the pnml file
std::pair<bool, uint_fast64_t> numberOfInitialTokens(false, defaultNumberOfInitialTokens); std::pair<bool, uint_fast64_t> numberOfInitialTokens(false, defaultNumberOfInitialTokens);
std::pair<bool, int_fast64_t> capacity(false, defaultCapacity);
std::pair<bool, boost::optional<uint64_t>> capacity(false, boost::none);
// traverse attributes // traverse attributes
for (uint_fast64_t i = 0; i < node->getAttributes()->getLength(); ++i) { for (uint_fast64_t i = 0; i < node->getAttributes()->getLength(); ++i) {
@ -150,10 +150,9 @@ namespace storm {
} }
if (!capacity.first) { if (!capacity.first) {
// no information about the capacity is found // no information about the capacity is found
// use default capacity
STORM_PRINT_AND_LOG("unknown capacity (place=" + placeName + ")\n"); STORM_PRINT_AND_LOG("unknown capacity (place=" + placeName + ")\n");
} }
builder.addPlace(capacity.first ? capacity.second : -1, numberOfInitialTokens.first ? numberOfInitialTokens.second : 0, placeName);
builder.addPlace(capacity.second, numberOfInitialTokens.first ? numberOfInitialTokens.second : 0, placeName);
} }
void PnmlParser::traverseTransition(xercesc::DOMNode const* const node) { void PnmlParser::traverseTransition(xercesc::DOMNode const* const node) {

2
src/storm-gspn/storage/gspn/GspnBuilder.cpp

@ -13,7 +13,7 @@ namespace storm {
gspnName = name; gspnName = name;
} }
uint_fast64_t GspnBuilder::addPlace(int_fast64_t const& capacity, uint_fast64_t const& initialTokens, std::string const& name) {
uint_fast64_t GspnBuilder::addPlace(boost::optional<uint64_t> capacity, uint_fast64_t const& initialTokens, std::string const& name) {
auto newId = places.size(); auto newId = places.size();
auto place = storm::gspn::Place(newId); auto place = storm::gspn::Place(newId);
place.setCapacity(capacity); place.setCapacity(capacity);

2
src/storm-gspn/storage/gspn/GspnBuilder.h

@ -25,7 +25,7 @@ namespace storm {
* A capacity of -1 indicates an unbounded place. * A capacity of -1 indicates an unbounded place.
* @param initialTokens The number of inital tokens in the place. * @param initialTokens The number of inital tokens in the place.
*/ */
uint_fast64_t addPlace(int_fast64_t const& capacity = 1, uint_fast64_t const& initialTokens = 0, std::string const& name = "");
uint_fast64_t addPlace(boost::optional<uint64_t> capacity = 1, uint_fast64_t const& initialTokens = 0, std::string const& name = "");
void setPlaceLayoutInfo(uint64_t placeId, LayoutInfo const& layoutInfo); void setPlaceLayoutInfo(uint64_t placeId, LayoutInfo const& layoutInfo);

2
src/storm-gspn/storage/gspn/Place.cpp

@ -29,7 +29,7 @@ namespace storm {
return this->numberOfInitialTokens; return this->numberOfInitialTokens;
} }
void Place::setCapacity(uint64_t cap) {
void Place::setCapacity(boost::optional<uint64_t> cap) {
this->capacity = cap; this->capacity = cap;
} }

4
src/storm-gspn/storage/gspn/Place.h

@ -54,9 +54,9 @@ namespace storm {
* Sets the capacity of tokens of this place. * Sets the capacity of tokens of this place.
* *
* @param capacity The capacity of this place. A non-negative number represents the capacity. * @param capacity The capacity of this place. A non-negative number represents the capacity.
* The value -1 indicates that the capacity is not set.
* boost::none indicates that the flag is not set.
*/ */
void setCapacity(uint64_t capacity);
void setCapacity(boost::optional<uint64_t> capacity);
/*! /*!
* Returns the capacity of tokens of this place. * Returns the capacity of tokens of this place.

Loading…
Cancel
Save