X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=core%2FOptional.hh;h=3ac4d32faeabde6ec9e2b7b73928a7f35559847f;hb=a38c6d4c92d78d84a8c44543ee3a890e50432e35;hp=85e14757f23dc0710bacbf2bfcc0d525c40cd6b0;hpb=854bcf9644df495ca89cbe85dce4ec85ba7986d9;p=deliverable%2Ftitan.core.git diff --git a/core/Optional.hh b/core/Optional.hh index 85e1475..3ac4d32 100644 --- a/core/Optional.hh +++ b/core/Optional.hh @@ -25,7 +25,11 @@ enum optional_sel { OPTIONAL_UNBOUND, OPTIONAL_OMIT, OPTIONAL_PRESENT }; template -class OPTIONAL : public Base_Type { +class OPTIONAL : public Base_Type +#ifdef TITAN_RUNTIME_2 + , public RefdIndexInterface +#endif +{ /** The value, if present (owned by OPTIONAL) * In Runtime2 the pointer is null, when the value is not present. * In Runtime1 its presence is indicated by the optional_selection member. */ @@ -319,19 +323,13 @@ public: * 'inout' or 'out' parameter to a function (only in Runtime2). * Sets the optional value to present (this would be done by the indexing operation * anyway) and redirects the call to the optional value. */ - void add_refd_index(int index); + virtual void add_refd_index(int index); /** Called after an element of an optional record of/set of is passed as an * 'inout' or 'out' parameter to a function (only in Runtime2). * Redirects the call to the optional value. */ - void remove_refd_index(int index); + virtual void remove_refd_index(int index); #endif - - /** Called before an element of an optional record of/set of is passed as an - * 'inout' or 'out' parameter to a function. Returns the size of the record of/ - * set of. - * Redirects the call to the optional value. */ - int size_of(); }; #if HAVE_GCC(4,6) @@ -827,14 +825,20 @@ void OPTIONAL::add_refd_index(int index) { ++param_refs; set_to_present(); - optional_value->add_refd_index(index); + RefdIndexInterface* refd_opt_val = dynamic_cast(optional_value); + if (0 != refd_opt_val) { + refd_opt_val->add_refd_index(index); + } } template void OPTIONAL::remove_refd_index(int index) { --param_refs; - optional_value->remove_refd_index(index); + RefdIndexInterface* refd_opt_val = dynamic_cast(optional_value); + if (0 != refd_opt_val) { + refd_opt_val->remove_refd_index(index); + } } #endif @@ -1005,6 +1009,12 @@ OPTIONAL::XER_decode(const XERdescriptor_t& p_td, XmlReaderWrap& reader, // we already checked for exer==1 if (!check_namespace((const char*)reader.NamespaceUri(), p_td)) break; + // set to omit if the attribute is empty + const char * value = (const char *)reader.Value(); + if (strlen(value) == 0) { + break; + } + set_to_present(); optional_value->XER_decode(p_td, reader, flavor, emb_val); goto finished;