casacore
Loading...
Searching...
No Matches
RecordFieldId.h
Go to the documentation of this file.
1// # RecordFieldId.h: The identification of a record field
2// # Copyright (C) 1995,1996
3// # Associated Universities, Inc. Washington DC, USA.
4// #
5// # This library is free software; you can redistribute it and/or modify it
6// # under the terms of the GNU Library General Public License as published by
7// # the Free Software Foundation; either version 2 of the License, or (at your
8// # option) any later version.
9// #
10// # This library is distributed in the hope that it will be useful, but WITHOUT
11// # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12// # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13// # License for more details.
14// #
15// # You should have received a copy of the GNU Library General Public License
16// # along with this library; if not, write to the Free Software Foundation,
17// # Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18// #
19// # Correspondence concerning AIPS++ should be addressed as follows:
20// # Internet email: casa-feedback@nrao.edu.
21// # Postal address: AIPS++ Project Office
22// # National Radio Astronomy Observatory
23// # 520 Edgemont Road
24// # Charlottesville, VA 22903-2475 USA
25
26#ifndef CASA_RECORDFIELDID_H
27#define CASA_RECORDFIELDID_H
28
29// # Includes
30#include <casacore/casa/aips.h>
31#include <casacore/casa/BasicSL/String.h>
32
33namespace casacore { // # NAMESPACE CASACORE - BEGIN
34
35// # Forward Declarations
36class RecordInterface;
37
38// <summary>
39// The identification of a record field.
40// </summary>
41
42// <use visibility=export>
43// <reviewed reviewer="Mark Wieringa" date="1996/04/15" tests="tRecord">
44// </reviewed>
45
46// <prerequisite>
47// <li> <linkto class="RecordInterface">RecordInterface</linkto>.
48// </prerequisite>
49
50// <etymology>
51// RecordFieldId gives the identification of a field in a record.
52// </etymology>
53
54// <synopsis>
55// This class provides the user to identify a field in a record.
56// Identification can be done by means of the field name or by means
57// of its field number.
58// <br>For the programmer the most convenient way is probably the name,
59// because that is the natural identification.
60// However, identification by means of field number is much faster
61// and could be used when it is known.
62// </synopsis>
63
64// <example>
65// <srcblock>
66// void someFunc (const Record& record)
67// {
68// float value1 = record.asfloat ("name"); // identify by name
69// float value2 = record.asfloat (0); // identify by number
70// }
71// </srcBlock>
72// </example>
73
74// <motivation>
75// This class makes it possible that many functions in Record classes
76// have to be defined only once. The constructors of RecordFieldId
77// make it possible that a number and a string are automatically
78// converted, so the user does not have to instantiate a RecordFieldId
79// object explicitly.
80// </motivation>
81
82// # <todo asof="1996/03/12">
83// # </todo>
84
86 public:
87 // Construct it from a field number.
89
90 // Construct it from a field name.
91 // <group>
93 RecordFieldId(const std::string& name);
94 RecordFieldId(const Char* name);
95 // </group>
96
97 // Get the field number.
98 Int fieldNumber() const;
99
100 // Get the field name.
101 const String& fieldName() const;
102
103 // Is the id given by name?
104 Bool byName() const;
105
106 private:
110};
111
113
116
117inline RecordFieldId::RecordFieldId(const std::string& fieldName)
119
122
123inline Int RecordFieldId::fieldNumber() const { return number_p; }
124
125inline const String& RecordFieldId::fieldName() const { return name_p; }
126
127inline Bool RecordFieldId::byName() const { return byName_p; }
128
129} // namespace casacore
130
131#endif
Int fieldNumber() const
Get the field number.
const String & fieldName() const
Get the field name.
RecordFieldId(Int fieldNumber)
Construct it from a field number.
Bool byName() const
Is the id given by name?
String: the storage and methods of handling collections of characters.
Definition String.h:355
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
const Bool False
Definition aipstype.h:42
String name() const
Return the name of the field.
RecordInterface()
The default constructor creates an empty record with a variable structure.
int Int
Definition aipstype.h:48
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
const Bool True
Definition aipstype.h:41
char Char
Definition aipstype.h:44