casacore
|
#include <RecordField.h>
Public Member Functions | |
RecordFieldPtr () | |
This object does not point to any field, i.e. | |
RecordFieldPtr (RecordInterface &record, Int whichField) | |
Attach this field pointer to the given field. | |
RecordFieldPtr (RecordInterface &record, const RecordFieldId &) | |
void | attachToRecord (RecordInterface &record, Int whichField) |
Change our pointer to the supplied field. | |
void | attachToRecord (RecordInterface &record, const RecordFieldId &) |
void | detach () |
Point to no field in any Record. | |
T & | operator* () |
Provide access to the field's value. | |
const T & | operator* () const |
const T & | get () const |
void | define (const T &value) |
Store a value in the field using redefinition. | |
const String & | comment () const |
Get the comment of this field. | |
void | setComment (const String &comment) |
Set the comment for this field. | |
Int | fieldNumber () const |
Return the fieldnumber of this field. | |
String | name () const |
Return the name of the field. | |
Bool | isAttached () const |
Is this field pointer attached to a valid record? Operations which might cause it to become detached are: | |
Static Private Member Functions | |
static const T * | get_typed_ptr (RecordInterface *record, Int fieldNumber) |
Private Attributes | |
RecordInterface * | parent_p |
Int | fieldNumber_p |
Access to an individual field in a record.
Public interface
RecordFieldPtr indicates that an object of this type is pointing to a field in a record.
RecordFieldPtr allows access to the fields in a record object. A record object is an object of a class derived from RecordInterface. RecordFieldPtr<T>
objects can only be instantiated for types ‘T’ which are valid fields of a record object (e.g. Int, float, String, Record, TableRecord). It can, however, NOT be instantiated for a Table field, because Table fields are accessed indirectly via a TableKeyword object. Table fields have to be accessed directly through the TableRecord interface.
Internally, a RecordFieldPtr stores a Record pointer and field number. Therefore, if the order of fields in a Record is modified, or if the Record is restructured, a RecordFieldPtr is invalidated and should no longer be used.
The RecordFieldPtr is pointer-like in the sense that it points to an object that is physically inside of another object (the enclosing record object). Access to the value is obtained via the dereference operator (operator*()
) to emphasize the pointer like nature of these classes.
An alternative way to get access to the values is using the functions define and get. Note that in
the assignment (in line 3) and define (in line 4) are not equivalent. The assignment uses the normal Array assignment, thus it takes the Array conformance rules into account (an assign is only possible when the new array value conforms the current array value or when the current array value is empty). On the other hand, define does not take the current array value into account. Thus an array value can always be redefined.
However, note that if the field is defined with a non-fixed shape in the record description, a value must always conform that shape (in case of assignment as well as in case of define).
See the example in the Record class.
RecordFieldPtr provides a fast way to access the data in a record.
Definition at line 110 of file RecordField.h.
casacore::RecordFieldPtr< T >::RecordFieldPtr | ( | ) |
This object does not point to any field, i.e.
this->isAttached() == False;
casacore::RecordFieldPtr< T >::RecordFieldPtr | ( | RecordInterface & | record, |
Int | whichField | ||
) |
Attach this field pointer to the given field.
If it does not exist an exception is thrown.
casacore::RecordFieldPtr< T >::RecordFieldPtr | ( | RecordInterface & | record, |
const RecordFieldId & | |||
) |
void casacore::RecordFieldPtr< T >::attachToRecord | ( | RecordInterface & | record, |
const RecordFieldId & | |||
) |
void casacore::RecordFieldPtr< T >::attachToRecord | ( | RecordInterface & | record, |
Int | whichField | ||
) |
Change our pointer to the supplied field.
If it doesn't exist an exception is thrown.
const String & casacore::RecordFieldPtr< T >::comment | ( | ) | const |
Get the comment of this field.
void casacore::RecordFieldPtr< T >::define | ( | const T & | value | ) |
Store a value in the field using redefinition.
Define differs from assignment w.r.t. arrays. For define a variable shaped array is deleted first with the effect that array conformance rules are not applied for them.
void casacore::RecordFieldPtr< T >::detach | ( | ) |
Point to no field in any Record.
|
inline |
Return the fieldnumber of this field.
Definition at line 159 of file RecordField.h.
References casacore::RecordFieldPtr< T >::fieldNumber_p.
|
inline |
Definition at line 143 of file RecordField.h.
References casacore::RecordFieldPtr< T >::fieldNumber_p, casacore::RecordFieldPtr< T >::get_typed_ptr(), and casacore::RecordFieldPtr< T >::parent_p.
Referenced by casacore::RecordFieldPtr< T >::operator*().
|
staticprivate |
Referenced by casacore::RecordFieldPtr< T >::get().
|
inline |
Is this field pointer attached to a valid record? Operations which might cause it to become detached are:
Definition at line 174 of file RecordField.h.
References casacore::RecordFieldPtr< T >::parent_p.
|
inline |
Return the name of the field.
Definition at line 163 of file RecordField.h.
References casacore::RecordFieldPtr< T >::fieldNumber_p, casacore::RecordInterface::name(), and casacore::RecordFieldPtr< T >::parent_p.
Referenced by casacore::ColumnsIndex::copyKeyField().
T & casacore::RecordFieldPtr< T >::operator* | ( | ) |
Provide access to the field's value.
Note: To be sure a const function is called, it is best to use get(); For a non-const object, a non-const function is called, even if used as an rvalue;
|
inline |
Definition at line 142 of file RecordField.h.
References casacore::RecordFieldPtr< T >::get().
void casacore::RecordFieldPtr< T >::setComment | ( | const String & | comment | ) |
Set the comment for this field.
|
private |
Definition at line 181 of file RecordField.h.
Referenced by casacore::RecordFieldPtr< T >::fieldNumber(), casacore::RecordFieldPtr< T >::get(), and casacore::RecordFieldPtr< T >::name().
|
private |
Definition at line 180 of file RecordField.h.
Referenced by casacore::RecordFieldPtr< T >::get(), casacore::RecordFieldPtr< T >::isAttached(), and casacore::RecordFieldPtr< T >::name().