IF_FAIL_RETURN(attr, E_PARAM);
IF_FAIL_RETURN(attr->getType() == Attribute::Type::INTEGER, E_PARAM);
- static_cast<IntegerAttribute*>(attr)->addTarget(value);
+ if (!static_cast<IntegerAttribute*>(attr)->addTarget(value))
+ return E_INV_RULE;
return E_NONE;
}
IF_FAIL_RETURN(attr, E_PARAM);
IF_FAIL_RETURN(attr->getType() == Attribute::Type::STRING, E_PARAM);
- static_cast<StringAttribute*>(attr)->addTarget(value);
+ if (!static_cast<StringAttribute*>(attr)->addTarget(value))
+ return E_INV_RULE;
return E_NONE;
}
IF_FAIL_RETURN(attr, E_PARAM);
IF_FAIL_RETURN(attr->getType() == Attribute::Type::INTEGER, E_PARAM);
- static_cast<IntegerAttribute*>(attr)->addNonTarget(value);
+ if (!static_cast<IntegerAttribute*>(attr)->addNonTarget(value))
+ return E_INV_RULE;
return E_NONE;
}
IF_FAIL_RETURN(attr, E_PARAM);
IF_FAIL_RETURN(attr->getType() == Attribute::Type::STRING, E_PARAM);
- static_cast<StringAttribute*>(attr)->addNonTarget(value);
+ if (!static_cast<StringAttribute*>(attr)->addNonTarget(value))
+ return E_INV_RULE;
return E_NONE;
}
return __targets;
}
-IntegerAttribute& IntegerAttribute::setClosedLowerBound(int bound)
+void IntegerAttribute::setClosedLowerBound(int bound)
{
__closedLowerBound = std::max(__closedLowerBound, bound);
- return *this;
}
-IntegerAttribute& IntegerAttribute::setClosedUpperBound(int bound)
+void IntegerAttribute::setClosedUpperBound(int bound)
{
__closedUpperBound = std::min(__closedUpperBound, bound);
- return *this;
}
-IntegerAttribute& IntegerAttribute::setOpenLowerBound(int bound)
+void IntegerAttribute::setOpenLowerBound(int bound)
{
__openLowerBound = std::max(__openLowerBound, bound);
- return *this;
}
-IntegerAttribute& IntegerAttribute::setOpenUpperBound(int bound)
+void IntegerAttribute::setOpenUpperBound(int bound)
{
__openUpperBound = std::min(__openUpperBound, bound);
- return *this;
}
-IntegerAttribute& IntegerAttribute::addTarget(int target)
+bool IntegerAttribute::addTarget(int target)
{
+ if (__targets.find(target) != __targets.end())
+ return false;
+
__targets.insert(target);
- return *this;
+
+ return true;
}
-IntegerAttribute& IntegerAttribute::addNonTarget(int nonTarget)
+bool IntegerAttribute::addNonTarget(int nonTarget)
{
+ if (__nonTargets.find(nonTarget) != __nonTargets.end())
+ return false;
+
__nonTargets.insert(nonTarget);
- return *this;
+
+ return true;
}
void IntegerAttribute::toJson(Json::Value& jsonNode) const
return Attribute::Type::STRING;
}
-StringAttribute& StringAttribute::addTarget(const std::string& target)
+bool StringAttribute::addTarget(const std::string& target)
{
+ if (__targets.find(target) != __targets.end())
+ return false;
+
__targets.insert(target);
- return *this;
+
+ return true;
}
-StringAttribute& StringAttribute::addNonTarget(const std::string& nonTarget)
+bool StringAttribute::addNonTarget(const std::string& nonTarget)
{
+ if (__nonTargets.find(nonTarget) != __nonTargets.end())
+ return false;
+
__nonTargets.insert(nonTarget);
- return *this;
+
+ return true;
}
void StringAttribute::toJson(Json::Value& jsonNode) const
const std::set<int>& getTargets();
- IntegerAttribute& setClosedLowerBound(int bound);
- IntegerAttribute& setClosedUpperBound(int bound);
- IntegerAttribute& setOpenLowerBound(int bound);
- IntegerAttribute& setOpenUpperBound(int bound);
- IntegerAttribute& addTarget(int target);
- IntegerAttribute& addNonTarget(int nonTarget);
+ void setClosedLowerBound(int bound);
+ void setClosedUpperBound(int bound);
+ void setOpenLowerBound(int bound);
+ void setOpenUpperBound(int bound);
+ bool addTarget(int target);
+ bool addNonTarget(int nonTarget);
void toJson(Json::Value& jsonNode) const;
Attribute::Type getType() const;
- StringAttribute& addTarget(const std::string& target);
- StringAttribute& addNonTarget(const std::string& nonTarget);
+ bool addTarget(const std::string& target);
+ bool addNonTarget(const std::string& nonTarget);
void toJson(Json::Value& jsonNode) const;