casacore
|
#include <RecordField.h>
Public Member Functions | |
RecordFieldPtr () | |
This object does not point to any field, i.e. More... | |
RecordFieldPtr (RecordInterface &record, Int whichField) | |
Attach this field pointer to the given field. More... | |
RecordFieldPtr (RecordInterface &record, const RecordFieldId &) | |
RecordFieldPtr (const RecordFieldPtr< T > &other) | |
After calling, this and other point to the same field, i.e. More... | |
RecordFieldPtr< T > & | operator= (const RecordFieldPtr< T > &other) |
~RecordFieldPtr () | |
void | attachToRecord (RecordInterface &record, Int whichField) |
Change our pointer to the supplied field. More... | |
void | attachToRecord (RecordInterface &record, const RecordFieldId &) |
void | detach () |
Point to no field in any Record. More... | |
T & | operator* () |
Provide access to the field's value. More... | |
const T & | operator* () const |
const T & | get () const |
void | define (const T &value) |
Store a value in the field using redefinition. More... | |
const String & | comment () const |
Get the comment of this field. More... | |
void | setComment (const String &comment) |
Set the comment for this field. More... | |
Int | fieldNumber () const |
Return the fieldnumber of this field. More... | |
String | name () const |
Return the name of the field. More... | |
Bool | isAttached () const |
Is this field pointer attached to a valid record? Operations which might cause it to become detached are: More... | |
Public Member Functions inherited from casacore::NoticeTarget | |
virtual | ~NoticeTarget () |
Destructs this NoticeTarget . More... | |
Bool | isValid () const |
Returns a boolean value telling whether this NoticeTarget is still "valid". More... | |
Bool | isAttached () const |
Returns a boolean value telling whether this NoticeTarget is still attached to a NoticeSource or not. More... | |
void | invalidate () |
Makes the current NoticeTarget "invalid". More... | |
Private Member Functions | |
virtual void | notify (const Notice &message) |
Not important for users - the mechanism by which field pointers are notified when there is a change in the record. More... | |
Private Attributes | |
T * | fieldPtr_p |
RecordInterface * | parent_p |
Int | fieldNumber_p |
Additional Inherited Members | |
Protected Member Functions inherited from casacore::NoticeTarget | |
NoticeTarget () | |
Creates an unlinked, "invalid" NoticeTarget . More... | |
NoticeTarget (NoticeSource *v) | |
Creates a "valid" NoticeTarget linked to the specified NoticeSource . More... | |
NoticeTarget (NoticeSource &v) | |
NoticeTarget (NoticeTarget &other) | |
Creates a "valid" NoticeTarget linked to the same NoticeSource as the other NoticeTarget . More... | |
NoticeTarget (NoticeTarget *other) | |
void | unlink () |
Unlinks this NoticeTarget from its NoticeSource . More... | |
void | link (const NoticeTarget &other) |
Links this NoticeTarget to the same NoticeSource as the other NoticeTarget . More... | |
void | link (const NoticeTarget *other) |
Link< NoticeTarget * > * | next () |
Retrieves the next NoticeTarget in the target list of the associated NoticeSource . More... | |
const Link< NoticeTarget * > * | next () const |
void | attach (NoticeSource *v) |
Adds this NoticeTarget to the target list in the specified NoticeSource , so that it will receive all notices sent out by that NoticeSource . More... | |
void | attach (NoticeSource &v) |
Protected Attributes inherited from casacore::NoticeTarget | |
Link< NoticeTarget * > * | ilink |
NoticeSource * | container |
Bool | valid |
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.
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).
RecordFieldPtr is derived from NoticeTarget to get messages from the mother record class when it changes. For example, when the record is destructed, all RecordFieldPtr's pointing to that record will automatically be detached.
See the example in the Record class.
RecordFieldPtr provides a fast way to access the data in a record.
Definition at line 118 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 & | |||
) |
casacore::RecordFieldPtr< T >::RecordFieldPtr | ( | const RecordFieldPtr< T > & | other | ) |
After calling, this and other point to the same field, i.e.
it uses reference semantics.
casacore::RecordFieldPtr< T >::~RecordFieldPtr | ( | ) |
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 176 of file RecordField.h.
References casacore::RecordFieldPtr< T >::fieldNumber_p.
|
inline |
Definition at line 160 of file RecordField.h.
References casacore::RecordFieldPtr< T >::fieldPtr_p.
|
inline |
Is this field pointer attached to a valid record? Operations which might cause it to become detached are:
Definition at line 191 of file RecordField.h.
References casacore::NoticeTarget::isAttached().
|
inline |
Return the name of the field.
Definition at line 180 of file RecordField.h.
References casacore::RecordFieldPtr< T >::fieldNumber_p, casacore::RecordInterface::name(), and casacore::RecordFieldPtr< T >::parent_p.
Referenced by casacore::ColumnsIndex::copyKeyField().
|
privatevirtual |
Not important for users - the mechanism by which field pointers are notified when there is a change in the record.
Implements casacore::NoticeTarget.
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 159 of file RecordField.h.
References casacore::RecordFieldPtr< T >::fieldPtr_p.
RecordFieldPtr<T>& casacore::RecordFieldPtr< T >::operator= | ( | const RecordFieldPtr< T > & | other | ) |
void casacore::RecordFieldPtr< T >::setComment | ( | const String & | comment | ) |
Set the comment for this field.
|
private |
Definition at line 197 of file RecordField.h.
Referenced by casacore::RecordFieldPtr< T >::fieldNumber(), and casacore::RecordFieldPtr< T >::name().
|
private |
Definition at line 195 of file RecordField.h.
Referenced by casacore::RecordFieldPtr< T >::get(), and casacore::RecordFieldPtr< T >::operator*().
|
private |
Definition at line 196 of file RecordField.h.
Referenced by casacore::RecordFieldPtr< T >::name().