conga/ricci include/Variable.h common/Variable ...
CVSROOT: /cvs/cluster
Module name: conga
Changes by: kupcevic at sourceware.org 2006-09-26 01:04:21
Modified files:
ricci/include : Variable.h
ricci/common : Variable.cpp
ricci/modules/storage: Props.h Props.cpp
ricci/docs : variables.html
Log message:
ricci: add bool conditionals for variables
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/include/Variable.h.diff?cvsroot=cluster&r1=1.3&r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/common/Variable.cpp.diff?cvsroot=cluster&r1=1.7&r2=1.8
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/Props.h.diff?cvsroot=cluster&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/Props.cpp.diff?cvsroot=cluster&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/docs/variables.html.diff?cvsroot=cluster&r1=1.4&r2=1.5
ricci/include/Variable.h +13 -0
@@ -183,6 +183,16 @@ XMLObject xml() const; + + void set_conditional_bool_if(const String& bool_name); + String get_conditional_bool_if() const + {return _cond_bool_if; } + + void set_conditional_bool_ifnot(const String& bool_name); + String get_conditional_bool_ifnot() const + {return _cond_bool_ifnot; } + +// values getters and setters void set_value (long long value);
@@ -217,6 +227,9 @@bool _mutable; +String _cond_bool_if; +String _cond_bool_ifnot; +Validator _validator; };// class Variable
ricci/common/Variable.cpp +33 -5
@@ -45,9 +45,11 @@ _mutable = (xml.get_attr("mutable") == "true"); + // _validator = Validator(xml); // incoming constraints are not to be trusted anyhow - // _validator = Validator(xml); // incoming limits are not to be trusted anyhow - + // conditionals + _cond_bool_if = xml.get_attr("if_bool"); + _cond_bool_ifnot = xml.get_attr("ifnot_bool"); String type(xml.get_attr("type")); if (type == VARIABLE_INT) {
@@ -239,6 +241,22 @@ {} +void +Variable::set_conditional_bool_if(const String& bool_name) +{ + if (name() == bool_name) + throw String("circular conditional: ") + bool_name; + _cond_bool_if = bool_name; +} + +void +Variable::set_conditional_bool_ifnot(const String& bool_name) +{ + if (name() == bool_name) + throw String("circular conditional: ") + bool_name; + _cond_bool_ifnot = bool_name; +} + long long Variable::get_int() const
@@ -356,7 +374,9 @@ Variable::equal(const Variable& var) const { if (type() != var.type() || - name() != var.name()) + name() != var.name() || + get_conditional_bool_if() != var.get_conditional_bool_if() || + get_conditional_bool_ifnot() != var.get_conditional_bool_ifnot()) return false; switch (var.type()) { case Integer:
@@ -391,7 +411,10 @@ if (name() != var.name()) throw String("different variable names"); if (type() != var.type()) - throw String("different variable types"); + throw String("invalid variable type"); + if (get_conditional_bool_if() != var.get_conditional_bool_if() || + get_conditional_bool_ifnot() != var.get_conditional_bool_ifnot()) + throw String("invalid bool conditional"); switch (var.type()) { case Integer:
@@ -419,7 +442,7 @@ { XMLObject xml(VARIABLE_TAG); - xml.set_attr("name", _name); + xml.set_attr("name", name()); xml.set_attr("mutable", (_mutable)?"true":"false"); int i = 0;
@@ -490,6 +513,11 @@ if (_mutable) _validator.export_params(xml); + if (!_cond_bool_if.empty()) + xml.set_attr("if_bool", _cond_bool_if); + if (!_cond_bool_ifnot.empty()) + xml.set_attr("ifnot_bool", _cond_bool_ifnot); + return xml; }
ricci/modules/storage/Props.h +5 -2
@@ -40,10 +40,11 @@ Props(const XMLObject&); virtual ~Props(); - const Variable& get(const String& name) const; - Variable& get(const String& name); + const Variable get(const String& name) const; void set(const Variable& var); + bool is_active(const Variable& var) const; + void validate() const; void validate(const Props& props) const; // validate props against *this
@@ -55,6 +56,8 @@ std::map<String, Variable> _vars; + void _set(const Variable& var); + };
ricci/modules/storage/Props.cpp +41 -18
95 lines not on this page · raw message
ricci/docs/variables.html +10 -4
@@ -5,15 +5,21 @@ <TITLE>Variables</TITLE> <META NAME="GENERATOR" CONTENT="OpenOffice.org 1.1.2 (Linux)"> <META NAME="CREATED" CONTENT="20060410;13011800"> - <META NAME="CHANGED" CONTENT="20060412;18255000"> + <META NAME="CHANGED" CONTENT="20060626;16203200"> </HEAD> <BODY LANG="en-US" DIR="LTR"> <P><var/> represents a variable. <BR>It has ???name???, ???type??? and ???mutable??? attributes. Optionally, dependent on ???type???, it might have ???value??? attribute as well. If variable is ???mutable???, -it will have constraints (constraints depend on ???type???). +it will have constraints (constraints depend on ???type???). <BR>Besides +constraints, conditionals can be present as well:<BR> - If a variable +has an if_bool=???bool_var_name??? attribute, it is to be used only if +boolean variable named ???bool_var_name??? is set to ???true???.<BR> +- If a variable has an ifnot_bool=???bool_var_name??? attribute, it is to +be used only if boolean variable named ???bool_var_name??? is set to +???false???.</P> +<P>Types: </P> -<P>Types:</P> <UL> <LI><P>int</P> <UL>
@@ -99,4 +105,4 @@ <P><BR><BR> </P> </BODY> -</HTML> +</HTML>