#include <AttrTable.h>
Inheritance diagram for AttrTable:
Instance management functions | |
AttrTable (const AttrTable &rhs) | |
AttrTable () | |
AttrTable & | operator= (const AttrTable &rhs) |
virtual | ~AttrTable () |
Public Types | |
typedef std::vector< entry * >::const_iterator | Attr_citer |
typedef std::vector< entry * >::iterator | Attr_iter |
Public Member Functions | |
void | add_container_alias (const string &name, AttrTable *src) |
Add an alias to a container held by this attribute table. | |
void | add_value_alias (AttrTable *das, const string &name, const string &source) |
Add an alias for an attribute. | |
unsigned int | append_attr (const string &name, const string &type, vector< string > *values) |
Add an attribute to the table. | |
unsigned int | append_attr (const string &name, const string &type, const string &value) |
Add an attribute to the table. | |
AttrTable * | append_container (AttrTable *at, const string &name) |
Add a container to the attribute table. | |
AttrTable * | append_container (const string &name) |
Add a container to the attribute table. | |
bool | attr_alias (const string &alias, const string &name) |
bool | attr_alias (const string &alias, AttrTable *at, const string &name) |
Adds an alias to the set of attributes. | |
virtual void | dump (ostream &strm) const |
dumps information about this object | |
void | erase () |
Erase the attribute table. | |
void | find (const string &target, AttrTable **at, Attr_iter *iter) |
AttrTable * | find_container (const string &target) |
Find an attribute with a given name. | |
string | get_name () const |
Get the name of this attribute table. | |
AttrTable * | get_parent () const |
unsigned int | get_size () const |
Get the number of entries in this attribute table. | |
void | print (FILE *out, string pad=" ", bool dereference=false) |
Prints the attribute table. | |
void | print_xml (FILE *out, string pad=" ", bool constrained=false) |
AttrTable * | recurrsive_find (const string &target, Attr_iter *location) |
void | set_name (const string &n) |
Set the name of this attribute table. | |
Protected Member Functions | |
void | clone (const AttrTable &at) |
void | simple_print (FILE *out, string pad, Attr_iter i, bool dereference) |
Friends | |
class | AttrTableTest |
Classes | |
struct | entry |
AttrType
list. However, all attribute types are stored as string data, except for the container type, which is stored as a pointer to another attribute table.Each element in the attribute table can itself be an attribute table. The table can also contain ``alias'' attributes whose value is given by the value of another attribute to which it is linked.
The attribute tables have a standard printed representation. There is a member function print()
for writing this form. Use the DAS::parse()
function to read the printed form.
An attribute table might look something like this:
string long_name "Weekly Means of Sea Surface Temperature"; actual_range { Float64 min -1.8; Float64 max 35.09; } string units "degC"; conversion_data { Float64 add_offset 0.; Float64 scale_factor 0.0099999998; } Int32 missing_value 32767;
Here, long_name
, units
, and missing_value
are simple attributes, and actual_range
and conversion_data
are container attributes containing other attribute tables.
Definition at line 141 of file AttrTable.h.
typedef std::vector<entry *>::const_iterator AttrTable::Attr_citer |
Definition at line 226 of file AttrTable.h.
typedef std::vector<entry *>::iterator AttrTable::Attr_iter |
Definition at line 227 of file AttrTable.h.
AttrTable::AttrTable | ( | ) |
AttrTable::AttrTable | ( | const AttrTable & | rhs | ) |
Definition at line 126 of file AttrTable.cc.
References clone().
Here is the call graph for this function:
AttrTable::~AttrTable | ( | ) | [virtual] |
void AttrTable::add_container_alias | ( | const string & | name, | |
AttrTable * | src | |||
) |
name | The name of the alias. May not use dot notation. | |
src | The existing attribute container to alias. |
Error | if an attribute, container or alias called name already exists in this attribute table. |
Definition at line 789 of file AttrTable.cc.
References AttrTable::entry::aliased_to, Attr_container, attr_end(), AttrTable::entry::attributes, get_name(), AttrTable::entry::is_alias, AttrTable::entry::name, AttrTable::entry::type, and www2id().
Here is the call graph for this function:
void AttrTable::add_value_alias | ( | AttrTable * | das, | |
const string & | name, | |||
const string & | source | |||
) |
Assume source names an attribute value in some container. Add an alias name for that value in this object.
das | ||
name | The name of the alias. May not use dot notation. | |
source | The name of the attribute to alias. May use dot notation. |
Error | if the attribute table already contains an attribute, container or alias called name or if an attribute called source does not exist. |
Definition at line 821 of file AttrTable.cc.
References AttrTable::entry::aliased_to, AttrTable::entry::attr, Attr_container, attr_end(), AttrTable::entry::attributes, find(), get_attr_table(), get_attr_type(), AttrTable::entry::is_alias, is_container(), AttrTable::entry::name, AttrTable::entry::type, and www2id().
Referenced by attr_alias().
Here is the call graph for this function:
unsigned int AttrTable::append_attr | ( | const string & | name, | |
const string & | type, | |||
vector< string > * | values | |||
) |
This version of append_attr() takes a vector<string> of values. If the given name already refers to an attribute, and the attribute has values, append the new values to the existing ones.
The function throws an Error if the attribute is a container, or if the type of the input value does not match the existing attribute's type. Use append_container()
to add container attributes.
This method performs a simple search for name
in this attribute table only; sub-tables are not searched and the dot notation is not recognized.
name | The name of the attribute to add or modify. | |
type | The type of the attribute to add or modify. | |
values | A vector of values. |
Definition at line 257 of file AttrTable.cc.
References AttrTable::entry::attr, get_type(), AttrTable::entry::is_alias, AttrTable::entry::name, String_to_AttrType(), AttrTable::entry::type, and www2id().
Here is the call graph for this function:
unsigned int AttrTable::append_attr | ( | const string & | name, | |
const string & | type, | |||
const string & | attribute | |||
) |
If the given name already refers to an attribute, and the attribute has a value, the given value is appended to the attribute vector. Calling this function repeatedly is the way to append to an attribute vector.
The function throws an Error if the attribute is a container, or if the type of the input value does not match the existing attribute's type. Use append_container()
to add container attributes.
This method performs a simple search for name
in this attribute table only; sub-tables are not searched and the dot notation is not recognized.
name | The name of the attribute to add or modify. | |
type | The type of the attribute to add or modify. | |
attribute | The value to add to the attribute table. |
Definition at line 204 of file AttrTable.cc.
References AttrTable::entry::attr, get_type(), AttrTable::entry::is_alias, AttrTable::entry::name, String_to_AttrType(), AttrTable::entry::type, and www2id().
Referenced by DDXParser::ddx_end_element(), DDS::transfer_attributes(), and Constructor::transfer_attributes().
Here is the call graph for this function:
Append a new attribute container to this attribute table. The new container is at
and its name is set to name
. If this attribute table already contains an attribute container called name
an exception is thrown.
Definition at line 331 of file AttrTable.cc.
References Attr_container, attr_end(), AttrTable::entry::attributes, d_parent, DBG, AttrTable::entry::is_alias, AttrTable::entry::name, set_name(), AttrTable::entry::type, and www2id().
Here is the call graph for this function:
AttrTable * AttrTable::append_container | ( | const string & | name | ) |
Create and append an attribute container to this AttrTable. If this attribute table already contains an attribute container called name
an exception is thrown.
Definition at line 303 of file AttrTable.cc.
Referenced by DAS::add_table(), DAS::DAS(), DDS::find_matching_container(), Constructor::find_matching_container(), DDS::transfer_attributes(), and Constructor::transfer_attributes().
bool AttrTable::attr_alias | ( | const string & | alias, | |
const string & | name | |||
) |
alias | The alias to insert into the attribute table. | |
name | The name of the already-existing attribute to which the alias will refer. |
Definition at line 901 of file AttrTable.cc.
References attr_alias().
Here is the call graph for this function:
bool AttrTable::attr_alias | ( | const string & | alias, | |
AttrTable * | at, | |||
const string & | name | |||
) |
Once an alias is inserted into an attribute table, reading the attributes for alias will return those stored for name.
Two forms for this function exist: one searches for name in the AttrTable referenced by at while the other uses this
. You can use DAS::get_attr_table()
to get the attribute table for an arbitrary name.
alias | The alias to insert into the attribute table. | |
name | The name of the already-existing attribute to which the alias will refer. | |
at | An attribute table in which to insert the alias. |
Definition at line 887 of file AttrTable.cc.
References add_value_alias().
Referenced by attr_alias().
Here is the call graph for this function:
AttrTable::Attr_iter AttrTable::attr_begin | ( | ) |
Get an iterator to the first entry in this attribute table.
Definition at line 609 of file AttrTable.cc.
Referenced by print_xml(), recurrsive_find(), DDS::transfer_attributes(), Constructor::transfer_attributes(), and DAS::var_begin().
AttrTable::Attr_iter AttrTable::attr_end | ( | ) |
Get an iterator to the end attribute table. Does not point to the last attribute in the table
Definition at line 618 of file AttrTable.cc.
Referenced by add_container_alias(), add_value_alias(), append_container(), print_xml(), recurrsive_find(), DDS::transfer_attributes(), Constructor::transfer_attributes(), and DAS::var_end().
void AttrTable::clone | ( | const AttrTable & | at | ) | [protected] |
Clone the given attribute table in this
. Protected.
Definition at line 106 of file AttrTable.cc.
References attr_map, d_name, and d_parent.
Referenced by AttrTable(), and operator=().
void AttrTable::del_attr | ( | const string & | name, | |
int | i = -1 | |||
) |
Delete the attribute named name
. If i
is given, and the attribute has a vector value, delete the i
$^th$ element of the vector.
You can use this function to delete container attributes, although the i
parameter has no meaning for that operation.
name | The name of the attribute to delete. This can be an attribute of any type, including containers. However, this method looks only in this attribute table and does not recognize the dot notation. | |
i | If the named attribute is a vector, and i is non-negative, the i-th entry in the vector is deleted, and the array is repacked. If i equals -1 (the default), the entire attribute is deleted. |
Definition at line 577 of file AttrTable.cc.
References AttrTable::entry::attr, Attr_container, and www2id().
Here is the call graph for this function:
AttrTable::Attr_iter AttrTable::del_attr_table | ( | Attr_iter | iter | ) |
Delete the iterator. Since AttrTable stores pointers to AttrTable objects, the caller should be sure to delete the AttrTable itself. This method does not take care of that operation.
iter | points to the entry to be deleted. |
Definition at line 673 of file AttrTable.cc.
References Attr_container.
void AttrTable::dump | ( | ostream & | strm | ) | const [virtual] |
Displays the pointer value of this instance and all attributes stored
strm | C++ i/o stream to dump the information to |
Implements DapObj.
Reimplemented in DAS.
Definition at line 1044 of file AttrTable.cc.
References Attr_container, AttrType_to_String(), DapIndent::Indent(), DapIndent::LMarg(), and DapIndent::UnIndent().
Referenced by DDS::dump(), DAS::dump(), and BaseType::dump().
Here is the call graph for this function:
void AttrTable::erase | ( | ) |
Erase the entire attribute table. This returns an AttrTable to the empty state that's the same as the object generated by the null constructor.
Definition at line 910 of file AttrTable.cc.
Referenced by AISMerge::merge().
Look for an attribute or an attribute container. If used to search for an attribute container, this method returns the container's parent using the value-result parameter at
and a reference to the container using the iterator value-result parameter iter
. If used to search for an attribute, the attribute's container is returned using at
; the attribute itself can be accessed using the iterator iter
.
target | The name (using dot notation) of the attribute or container to find. | |
at | A value-result used to return the attribute container in which target was found. Null if target was not found. | |
iter | The iterator which will reference the attribute found. Can be used to access target from within at . References dim_end() within at if the attribute or container does not exist. |
Definition at line 370 of file AttrTable.cc.
References find_container(), and recurrsive_find().
Referenced by add_value_alias(), and find_container().
Here is the call graph for this function:
AttrTable * AttrTable::find_container | ( | const string & | target | ) |
Look in this attribute table for an attribute container named target
. The search starts at this attribute table; target
should use the dot notation to name containers held within children of this attribute table.
To search the entire DAS object, make sure to invoke this method from that object.
target | The attribute container to find. |
Definition at line 464 of file AttrTable.cc.
References find(), and find_container().
Referenced by DAS::das_find(), find(), find_container(), DDS::find_matching_container(), Constructor::find_matching_container(), and get_attr_table().
Here is the call graph for this function:
string AttrTable::get_attr | ( | Attr_iter | iter, | |
unsigned int | i = 0 | |||
) |
Returns the value of an attribute. If the attribute has a vector value, you can indicate which is the desired value with the index argument, i. If the argument is omitted, the first value is returned. If the attribute has only a single value, the index argument is ignored. If i is greater than the number of elements in the attribute, an error is produced.
All values in an attribute table are stored as string data. They may be converted to a more appropriate internal format by the calling program.
iter | Reference to an attribute | |
i | The attribute value index, zero-based. Default value: 0 |
Definition at line 733 of file AttrTable.cc.
References Attr_container.
string AttrTable::get_attr | ( | const string & | name, | |
unsigned int | i = 0 | |||
) |
AttrTable::Attr_iter AttrTable::get_attr_iter | ( | int | i | ) |
Given an index i
, return the Attr_iter
to the corresponding element. This method provides a way to use all the methods that take an Attr_iter
using a simple integer index. Use the get_attr_num() or get_size() methods to determine how many items the AttrTable contains.
i | The index |
Definition at line 632 of file AttrTable.cc.
unsigned int AttrTable::get_attr_num | ( | Attr_iter | iter | ) |
If the attribute referenced by iter is a container attribute, this method returns the number of attributes in its attribute table. If the indicated attribute is not a container, the method returns the number of values for the attribute (1 for a scalar attribute, N for a vector attribute value).
iter | Reference to an attribute |
Definition at line 708 of file AttrTable.cc.
References Attr_container.
unsigned int AttrTable::get_attr_num | ( | const string & | name | ) |
If the indicated attribute is a container attribute, this function returns the number of attributes in its attribute table. If the indicated attribute is not a container, the method returns the number of values for the attribute (1 for a scalar attribute, N for a vector attribute value).
Definition at line 535 of file AttrTable.cc.
Referenced by print_xml().
Get the attribute container referenced by iter. If no such container exists, then return a reference to the end of the table.
iter | Reference to a table contained by this object. |
Definition at line 659 of file AttrTable.cc.
References Attr_container.
AttrTable * AttrTable::get_attr_table | ( | const string & | name | ) |
Definition at line 505 of file AttrTable.cc.
References find_container().
Referenced by add_value_alias(), DAS::get_table(), and print_xml().
Here is the call graph for this function:
Get the type of the attribute referenced by iter.
iter |
Definition at line 695 of file AttrTable.cc.
AttrType AttrTable::get_attr_type | ( | const string & | name | ) |
AttrType
value describing the attribute. Definition at line 521 of file AttrTable.cc.
References Attr_unknown.
Referenced by add_value_alias().
vector< string > * AttrTable::get_attr_vector | ( | Attr_iter | iter | ) |
Returns a pointer to the vector of values associated with the attribute referenced by iterator iter.
Note that all values in an attribute table are stored as string data. They may be converted to a more appropriate internal format by the calling program.
iter | Reference to the Attribute. |
Definition at line 774 of file AttrTable.cc.
References Attr_container.
vector< string > * AttrTable::get_attr_vector | ( | const string & | name | ) |
Get a pointer to the vector of values associated with the attribute referenced by Pix p
or named name
.
Note that all values in an attribute table are stored as string data. They may be converted to a more appropriate internal format by the calling program.
Definition at line 554 of file AttrTable.cc.
Referenced by DDS::transfer_attributes(), and Constructor::transfer_attributes().
string AttrTable::get_name | ( | Attr_iter | iter | ) |
Returns the name of the attribute referenced by iter.
Definition at line 639 of file AttrTable.cc.
string AttrTable::get_name | ( | ) | const |
Definition at line 173 of file AttrTable.cc.
Referenced by add_container_alias(), DAS::get_name(), print(), print_xml(), simple_print(), DDS::transfer_attributes(), and Constructor::transfer_attributes().
AttrTable* AttrTable::get_parent | ( | ) | const [inline] |
Return a pointer to the AttrTable which holds this table (aka, its parent. If this AttrTable has no parent, this returns null.
Definition at line 261 of file AttrTable.h.
unsigned int AttrTable::get_size | ( | ) | const |
Attributes that are containers count one attribute, as do attributes with both scalar and vector values.
Definition at line 165 of file AttrTable.cc.
Referenced by AISMerge::merge().
string AttrTable::get_type | ( | Attr_iter | iter | ) |
Get the type name of an attribute referenced by iter.
iter | Reference to the Attribute. |
Definition at line 685 of file AttrTable.cc.
References AttrType_to_String().
Here is the call graph for this function:
string AttrTable::get_type | ( | const string & | name | ) |
Definition at line 512 of file AttrTable.cc.
Referenced by append_attr(), print_xml(), simple_print(), DDS::transfer_attributes(), and Constructor::transfer_attributes().
bool AttrTable::is_container | ( | Attr_iter | i | ) |
Returns true if the attribute referenced by i is a container.
Definition at line 648 of file AttrTable.cc.
References Attr_container.
Referenced by add_value_alias(), and print_xml().
Definition at line 148 of file AttrTable.cc.
References clone().
Here is the call graph for this function:
void AttrTable::print | ( | FILE * | out, | |
string | pad = " " , |
|||
bool | dereference = false | |||
) |
Prints an ASCII representation of the attribute table to the indicated FILE pointer. The pad
argument is prefixed to each line of the output to provide control of indentation.
out | Print to the given output FILE. | |
pad | Indent elements of a table using this string of spaces. By default this is a string of four spaces | |
dereference | If true, follow aliases. Default is false. |
Definition at line 964 of file AttrTable.cc.
References get_name(), id2www(), and simple_print().
Referenced by DAS::print().
Here is the call graph for this function:
void AttrTable::print_xml | ( | FILE * | out, | |
string | pad = " " , |
|||
bool | constrained = false | |||
) |
Print the attribute table in XML.
out | Destination | |
pad | Indent lines of text/xml this much. Default is four spaces. | |
constrained | The DDX contains attribute information; is this DDX 'constrained?' |
Definition at line 990 of file AttrTable.cc.
References attr_begin(), attr_end(), get_attr(), get_attr_num(), get_attr_table(), get_name(), get_type(), id2xml(), is_container(), and print_xml().
Referenced by Grid::print_xml(), DDS::print_xml(), Constructor::print_xml(), BaseType::print_xml(), print_xml(), and Array::print_xml_core().
Here is the call graph for this function:
This method scans for attributes using recursion to look inside containers even when the name of the attribute is not fully qualified. It starts looking in itself and descends into its children depth first. It will find attributes and attribute containers.
target | Look for the attribute with this name. | |
location | A value-result parameter. This returns an iterator to the attribute within the returned AttrTable object |
Definition at line 409 of file AttrTable.cc.
References attr_begin(), Attr_container, and attr_end().
Referenced by find().
Here is the call graph for this function:
void AttrTable::set_name | ( | const string & | n | ) |
n | The new name of the attribute table. |
Definition at line 181 of file AttrTable.cc.
References www2id().
Referenced by append_container().
Here is the call graph for this function:
void AttrTable::simple_print | ( | FILE * | out, | |
string | pad, | |||
Attr_iter | i, | |||
bool | dereference | |||
) | [protected] |
A simple printer that does nothing fancy with aliases. Protected.
Definition at line 925 of file AttrTable.cc.
References Attr_container, get_name(), get_type(), and id2www().
Referenced by print().
Here is the call graph for this function:
friend class AttrTableTest [friend] |
Definition at line 239 of file AttrTable.h.