Browse Source

Places can only be cosntructed with their id, id cannot be changed later

Former-commit-id: 0bca8c74b6 [formerly 5f1551d2d6]
Former-commit-id: 8148521e6c
tempestpy_adaptions
sjunges 8 years ago
parent
commit
22167e9ec5
  1. 5
      src/storage/gspn/GspnBuilder.cpp
  2. 15
      src/storage/gspn/Place.cpp
  3. 19
      src/storage/gspn/Place.h

5
src/storage/gspn/GspnBuilder.cpp

@ -13,10 +13,9 @@ namespace storm {
}
uint_fast64_t GspnBuilder::addPlace(int_fast64_t const& capacity, uint_fast64_t const& initialTokens, std::string const& name) {
auto place = storm::gspn::Place();
place.setCapacity(capacity);
auto newId = places.size();
place.setID(newId);
auto place = storm::gspn::Place(newId);
place.setCapacity(capacity);
place.setNumberOfInitialTokens(initialTokens);
places.push_back(place);
return newId;

15
src/storage/gspn/Place.cpp

@ -5,6 +5,10 @@
namespace storm {
namespace gspn {
Place::Place(uint64_t id) : id(id) {
}
void Place::setName(std::string const& name) {
this->name = name;
}
@ -13,24 +17,19 @@ namespace storm {
return this->name;
}
void Place::setID(uint_fast64_t const& id) {
this->id = id;
}
uint_fast64_t Place::getID() const {
uint64_t Place::getID() const {
return this->id;
}
void Place::setNumberOfInitialTokens(uint_fast64_t const& tokens) {
void Place::setNumberOfInitialTokens(uint64_t tokens) {
this->numberOfInitialTokens = tokens;
}
uint_fast64_t Place::getNumberOfInitialTokens() const {
uint64_t Place::getNumberOfInitialTokens() const {
return this->numberOfInitialTokens;
}
void Place::setCapacity(uint64_t cap) {
std::cout << this->name << std::endl;
this->capacity = cap;
}

19
src/storage/gspn/Place.h

@ -11,6 +11,8 @@ namespace storm {
*/
class Place {
public:
Place(uint64_t id);
/*!
* Sets the name of this place. The name is not used to identify a place (and therefore do not have to be unique).
* Some input and output formats use the name to identify a place. If you want to use the export or import
@ -27,33 +29,26 @@ namespace storm {
*/
std::string getName() const;
/*!
* Sets the id of this place. The id must be unique for a gspn.
*
* @param id The new id of this place.
*/
void setID(uint_fast64_t const& id);
/*!
* Returns the id of this place.
*
* @return The id of this place.
*/
uint_fast64_t getID() const;
uint64_t getID() const;
/*!
* Sets the number of initial tokens of this place.
*
* @param tokens The number of initial tokens.
*/
void setNumberOfInitialTokens(uint_fast64_t const& tokens);
void setNumberOfInitialTokens(uint64_t tokens);
/*!
* Returns the number of initial tokens of this place.
*
* @return The number of initial tokens of this place.
*/
uint_fast64_t getNumberOfInitialTokens() const;
uint64_t getNumberOfInitialTokens() const;
/*!
* Sets the capacity of tokens of this place.
@ -76,10 +71,10 @@ namespace storm {
bool hasRestrictedCapacity() const;
private:
// contains the number of initial tokens of this place
uint_fast64_t numberOfInitialTokens = 0;
uint64_t numberOfInitialTokens = 0;
// unique id (is used to refer to a specific place in a bitvector)
uint_fast64_t id = 0;
uint64_t id = 0;
// name which is used in pnml file
std::string name;

Loading…
Cancel
Save