Документ взят из кэша поисковой машины. Адрес
оригинального документа
: http://www.atnf.csiro.au/computing/software/casacore/casacore-1.2.0/doc/html/RecordFieldId_8h_source.html
Дата изменения: Unknown Дата индексирования: Mon Feb 14 21:30:22 2011 Кодировка: Поисковые слова: universe |
00001 //# RecordFieldId.h: The identification of a record field 00002 //# Copyright (C) 1995,1996 00003 //# Associated Universities, Inc. Washington DC, USA. 00004 //# 00005 //# This library is free software; you can redistribute it and/or modify it 00006 //# under the terms of the GNU Library General Public License as published by 00007 //# the Free Software Foundation; either version 2 of the License, or (at your 00008 //# option) any later version. 00009 //# 00010 //# This library is distributed in the hope that it will be useful, but WITHOUT 00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00012 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00013 //# License for more details. 00014 //# 00015 //# You should have received a copy of the GNU Library General Public License 00016 //# along with this library; if not, write to the Free Software Foundation, 00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. 00018 //# 00019 //# Correspondence concerning AIPS++ should be addressed as follows: 00020 //# Internet email: aips2-request@nrao.edu. 00021 //# Postal address: AIPS++ Project Office 00022 //# National Radio Astronomy Observatory 00023 //# 520 Edgemont Road 00024 //# Charlottesville, VA 22903-2475 USA 00025 //# 00026 //# 00027 //# $Id: RecordFieldId.h 20551 2009-03-25 00:11:33Z Malte.Marquarding $ 00028 00029 00030 #ifndef CASA_RECORDFIELDID_H 00031 #define CASA_RECORDFIELDID_H 00032 00033 //# Includes 00034 #include <casa/aips.h> 00035 #include <casa/BasicSL/String.h> 00036 00037 namespace casa { //# NAMESPACE CASA - BEGIN 00038 00039 //# Forward Declarations 00040 class RecordInterface; 00041 00042 00043 // <summary> 00044 // The identification of a record field. 00045 // </summary> 00046 00047 // <use visibility=export> 00048 // <reviewed reviewer="Mark Wieringa" date="1996/04/15" tests="tRecord"> 00049 // </reviewed> 00050 00051 // <prerequisite> 00052 // <li> <linkto class="RecordInterface">RecordInterface</linkto>. 00053 // </prerequisite> 00054 00055 // <etymology> 00056 // RecordFieldId gives the identification of a field in a record. 00057 // </etymology> 00058 00059 // <synopsis> 00060 // This class provides the user to identify a field in a record. 00061 // Identification can be done by means of the field name or by means 00062 // of its field number. 00063 // <br>For the programmer the most convenient way is probably the name, 00064 // because that is the natural identification. 00065 // However, identification by means of field number is much faster 00066 // and could be used when it is known. 00067 // </synopsis> 00068 00069 // <example> 00070 // <srcblock> 00071 // void someFunc (const Record& record) 00072 // { 00073 // float value1 = record.asfloat ("name"); // identify by name 00074 // float value2 = record.asfloat (0); // identify by number 00075 // } 00076 // </srcBlock> 00077 // </example> 00078 00079 // <motivation> 00080 // This class makes it possible that many functions in Record classes 00081 // have to be defined only once. The constructors of RecordFieldId 00082 // make it possible that a number and a string are automatically 00083 // converted, so the user does not have to instantiate a RecordFieldId 00084 // object explicitly. 00085 // </motivation> 00086 00087 //# <todo asof="1996/03/12"> 00088 //# </todo> 00089 00090 00091 class RecordFieldId 00092 { 00093 public: 00094 // Construct it from a field number. 00095 RecordFieldId (Int fieldNumber); 00096 00097 // Construct it from a field name. 00098 // <group> 00099 RecordFieldId (const String& name); 00100 RecordFieldId (const std::string& name); 00101 RecordFieldId (const Char* name); 00102 // </group> 00103 00104 // Get the field number. 00105 Int fieldNumber() const; 00106 00107 // Get the field name. 00108 const String& fieldName() const; 00109 00110 // Is the id given by name? 00111 Bool byName() const; 00112 00113 private: 00114 Bool byName_p; 00115 Int number_p; 00116 String name_p; 00117 }; 00118 00119 00120 00121 inline RecordFieldId::RecordFieldId (Int fieldNumber) 00122 : byName_p (False), 00123 number_p (fieldNumber) 00124 {} 00125 00126 inline RecordFieldId::RecordFieldId (const String& fieldName) 00127 : byName_p (True), 00128 number_p (-1), 00129 name_p (fieldName) 00130 {} 00131 00132 inline RecordFieldId::RecordFieldId (const std::string& fieldName) 00133 : byName_p (True), 00134 number_p (-1), 00135 name_p (fieldName) 00136 {} 00137 00138 inline RecordFieldId::RecordFieldId (const Char* fieldName) 00139 : byName_p (True), 00140 number_p (-1), 00141 name_p (fieldName) 00142 {} 00143 00144 inline Int RecordFieldId::fieldNumber() const 00145 { 00146 return number_p; 00147 } 00148 00149 inline const String& RecordFieldId::fieldName() const 00150 { 00151 return name_p; 00152 } 00153 00154 inline Bool RecordFieldId::byName() const 00155 { 00156 return byName_p; 00157 } 00158 00159 00160 00161 } //# NAMESPACE CASA - END 00162 00163 #endif