Browse Source

Valuations now have methods to check whether they contain a given identifier.

Former-commit-id: 541c27d543
tempestpy_adaptions
dehnert 11 years ago
parent
commit
f60ea09cf4
  1. 30
      src/storage/expressions/SimpleValuation.cpp
  2. 10
      src/storage/expressions/SimpleValuation.h
  3. 25
      src/storage/expressions/Valuation.h

30
src/storage/expressions/SimpleValuation.cpp

@ -37,6 +37,36 @@ namespace storm {
this->identifierToValueMap[name] = value;
}
void SimpleValuation::removeIdentifier(std::string const& name) {
auto nameValuePair = this->identifierToValueMap.find(name);
LOG_THROW(nameValuePair != this->identifierToValueMap.end(), storm::exceptions::InvalidArgumentException, "Deleting unknown identifier '" << name << "'.");
this->identifierToValueMap.erase(nameValuePair);
}
bool SimpleValuation::containsBooleanIdentifier(std::string const& name) const {
auto nameValuePair = this->identifierToValueMap.find(name);
if (nameValuePair == this->identifierToValueMap.end()) {
return false;
}
return nameValuePair->second.type() == typeid(bool);
}
bool SimpleValuation::containsIntegerIdentifier(std::string const& name) const {
auto nameValuePair = this->identifierToValueMap.find(name);
if (nameValuePair == this->identifierToValueMap.end()) {
return false;
}
return nameValuePair->second.type() == typeid(int_fast64_t);
}
bool SimpleValuation::containsDoubleIdentifier(std::string const& name) const {
auto nameValuePair = this->identifierToValueMap.find(name);
if (nameValuePair == this->identifierToValueMap.end()) {
return false;
}
return nameValuePair->second.type() == typeid(double);
}
bool SimpleValuation::getBooleanValue(std::string const& name) const {
auto nameValuePair = this->identifierToValueMap.find(name);
LOG_THROW(nameValuePair != this->identifierToValueMap.end(), storm::exceptions::InvalidAccessException, "Access to unkown identifier '" << name << "'.");

10
src/storage/expressions/SimpleValuation.h

@ -78,7 +78,17 @@ namespace storm {
*/
void setDoubleValue(std::string const& name, double value);
/*!
* Removes the given identifier from this valuation.
*
* @param name The name of the identifier that is to be removed.
*/
void removeIdentifier(std::string const& name);
// Override base class methods.
virtual bool containsBooleanIdentifier(std::string const& name) const override;
virtual bool containsIntegerIdentifier(std::string const& name) const override;
virtual bool containsDoubleIdentifier(std::string const& name) const override;
virtual bool getBooleanValue(std::string const& name) const override;
virtual int_fast64_t getIntegerValue(std::string const& name) const override;
virtual double getDoubleValue(std::string const& name) const override;

25
src/storage/expressions/Valuation.h

@ -34,6 +34,31 @@ namespace storm {
* @return The value of the double identifier.
*/
virtual double getDoubleValue(std::string const& name) const = 0;
/*!
* Retrieves whether there exists a boolean identifier with the given name in the valuation.
*
* @param name The name of the boolean identifier to query.
* @return True iff the identifier exists and is of boolean type.
*/
virtual bool containsBooleanIdentifier(std::string const& name) const = 0;
/*!
* Retrieves whether there exists a integer identifier with the given name in the valuation.
*
* @param name The name of the integer identifier to query.
* @return True iff the identifier exists and is of boolean type.
*/
virtual bool containsIntegerIdentifier(std::string const& name) const = 0;
/*!
* Retrieves whether there exists a double identifier with the given name in the valuation.
*
* @param name The name of the double identifier to query.
* @return True iff the identifier exists and is of boolean type.
*/
virtual bool containsDoubleIdentifier(std::string const& name) const = 0;
};
}
}

Loading…
Cancel
Save