#include <TDataStd_RealArray.hxx>
#include <TDataStd_ExtStringArray.hxx>
+
+static Standard_GUID kInvalidGUID("caee5ce4-34b1-4b29-abcb-685287d18096");
+
+
Model_Expression::Model_Expression(TDF_Label& theLabel)
{
- myIsInitialized = true;
if (!theLabel.FindAttribute(TDataStd_Name::GetID(), myText)) {
myText = TDataStd_Name::Set(theLabel, TCollection_ExtendedString());
- myIsInitialized = false;
}
if (!theLabel.FindAttribute(TDataStd_Comment::GetID(), myError)) {
myError = TDataStd_Comment::Set(theLabel, TCollection_ExtendedString());
- myIsInitialized = false;
}
if (!theLabel.FindAttribute(TDataStd_ExtStringList::GetID(), myUsedParameters)) {
myUsedParameters = TDataStd_ExtStringList::Set(theLabel);
- myIsInitialized = false;
}
+}
+
+void Model_Expression::setText(const std::string& theValue)
+{
+ if (text() != theValue)
+ myText->Set(TCollection_ExtendedString(theValue.c_str()));
+
+ setError(text().empty() ? "" : "Not a double value.");
+}
+
+std::string Model_Expression::text() const
+{
+ return TCollection_AsciiString(myText->Get()).ToCString();
+}
+
+void Model_Expression::setError(const std::string& theError)
+{
+ if (error() != theError)
+ myError->Set(TCollection_ExtendedString(theError.c_str()));
+}
+
+std::string Model_Expression::error()
+{
+ return TCollection_AsciiString(myError->Get()).ToCString();
+}
+
+void Model_Expression::setUsedParameters(const std::set<std::string>& theUsedParameters)
+{
+ myUsedParameters->Clear();
+ std::set<std::string>::const_iterator anIt = theUsedParameters.begin();
+ for (; anIt != theUsedParameters.end(); ++anIt)
+ myUsedParameters->Append(TCollection_ExtendedString(anIt->c_str()));
+}
+
+std::set<std::string> Model_Expression::usedParameters() const
+{
+ std::set<std::string> aResult;
+ TDataStd_ListIteratorOfListOfExtendedString aIt;
+ for (aIt.Initialize(myUsedParameters->List()); aIt.More(); aIt.Next())
+ aResult.insert(TCollection_AsciiString(aIt.Value()).ToCString());
+ return aResult;
+}
+
+Model_ExpressionDouble::Model_ExpressionDouble(TDF_Label& theLabel)
+ : Model_Expression(theLabel)
+{
if (!theLabel.FindAttribute(TDataStd_Real::GetID(), myReal)) {
myReal = TDataStd_Real::Set(theLabel, 0.);
myIsInitialized = false;
}
}
}
-
- }
+ } else
+ myIsInitialized = true;
}
-void Model_Expression::setValue(const double theValue)
+void Model_ExpressionDouble::setValue(const double theValue)
{
if (value() != theValue)
myReal->Set(theValue);
}
-double Model_Expression::value()
+double Model_ExpressionDouble::value()
{
return myReal->Get();
}
-void Model_Expression::setText(const std::string& theValue)
-{
- if (text() != theValue)
- myText->Set(TCollection_ExtendedString(theValue.c_str()));
-
- setError(text().empty() ? "" : "Not a double value.");
-}
-
-std::string Model_Expression::text() const
-{
- return TCollection_AsciiString(myText->Get()).ToCString();
-}
-
-static Standard_GUID kInvalidGUID("caee5ce4-34b1-4b29-abcb-685287d18096");
-
-void Model_Expression::setInvalid(const bool theFlag)
+void Model_ExpressionDouble::setInvalid(const bool theFlag)
{
if (theFlag) {
TDataStd_UAttribute::Set(myReal->Label(), kInvalidGUID);
}
}
-bool Model_Expression::isInvalid()
+bool Model_ExpressionDouble::isInvalid()
{
return myReal->Label().IsAttribute(kInvalidGUID) == Standard_True;
}
-void Model_Expression::setError(const std::string& theError)
+
+Model_ExpressionInteger::Model_ExpressionInteger(TDF_Label& theLabel)
+ : Model_Expression(theLabel)
{
- if (error() != theError)
- myError->Set(TCollection_ExtendedString(theError.c_str()));
+ if (!theLabel.FindAttribute(TDataStd_Integer::GetID(), myInteger)) {
+ myInteger = TDataStd_Integer::Set(theLabel, 0);
+ myIsInitialized = false;
+ } else
+ myIsInitialized = true;
}
-std::string Model_Expression::error()
+void Model_ExpressionInteger::setValue(const int theValue)
{
- return TCollection_AsciiString(myError->Get()).ToCString();
+ if (value() != theValue)
+ myInteger->Set(theValue);
}
-void Model_Expression::setUsedParameters(const std::set<std::string>& theUsedParameters)
+int Model_ExpressionInteger::value()
{
- myUsedParameters->Clear();
- std::set<std::string>::const_iterator anIt = theUsedParameters.begin();
- for (; anIt != theUsedParameters.end(); ++anIt)
- myUsedParameters->Append(TCollection_ExtendedString(anIt->c_str()));
+ return myInteger->Get();
}
-std::set<std::string> Model_Expression::usedParameters() const
+void Model_ExpressionInteger::setInvalid(const bool theFlag)
{
- std::set<std::string> aResult;
- TDataStd_ListIteratorOfListOfExtendedString aIt;
- for (aIt.Initialize(myUsedParameters->List()); aIt.More(); aIt.Next())
- aResult.insert(TCollection_AsciiString(aIt.Value()).ToCString());
- return aResult;
+ if (theFlag) {
+ TDataStd_UAttribute::Set(myInteger->Label(), kInvalidGUID);
+ } else {
+ myInteger->Label().ForgetAttribute(kInvalidGUID);
+ }
+}
+
+bool Model_ExpressionInteger::isInvalid()
+{
+ return myInteger->Label().IsAttribute(kInvalidGUID) == Standard_True;
}