1 // 2 // This file is part of the SDTS++ toolkit, written by the U.S. 3 // Geological Survey. It is experimental software, written to support 4 // USGS research and cartographic data production. 5 // 6 // SDTS++ is public domain software. It may be freely copied, 7 // distributed, and modified. The USGS welcomes user feedback, but makes 8 // no committment to any level of support for this code. See the SDTS 9 // web site at http://mcmcweb.er.usgs.gov/sdts for more information, 10 // including points of contact. 11 // 12 // $Id: sb_Clrx.h,v 1.2 2001/05/22 05:58:34 mcoletti Exp $ 13 // 14 #ifndef INCLUDED_SB_CLRX_H 15 #define INCLUDED_SB_CLRX_H 16 17 #include <list> 18 #include <string> 19 20 #ifndef SB_MODULE_H 21 #include "builder/sb_Module.h" 22 #endif 23 24 25 #ifndef INCLUDED_SIO8211FIELDFORMAT_H 26 #include "io/sio_8211FieldFormat.h" 27 #endif 28 29 class sb_ForeignID; 30 class sc_Record; 31 32 33 // This class provides a convenient access to CLRX records. It provides 34 // members to access or set various module field and subfield values. 35 // It also provides a mechanism for populating an object of this class with 36 // values found in a valid sc_Record of this module, and for filling a 37 // sc_Record with the contents of a sb_Clrx object. 38 39 40 struct sb_Clrx_Imp; 41 42 class sb_Clrx : public sb_Module 43 { 44 public: 45 46 sb_Clrx(); 47 48 ~sb_Clrx(); 49 50 51 //@{ 52 /** 53 Use these members to get subfield/field values. Pass in an appropriate 54 type to receive the value. These members will return false if the 55 corresponding value is not set. (It may not be set because a value 56 was not assigned to it, or because you previously tried to assign 57 an invalid value.) Otherwise they will return true. 58 */ 59 bool getRedComponent( double& val ) const; getRED(double & val)60 bool getRED( double& val ) const { return getRedComponent( val ); } 61 62 bool getGreenComponent( double& val ) const; getGREN(double & val)63 bool getGREN( double& val ) const { return getGreenComponent( val ); } 64 65 bool getBlueComponent( double& val ) const; getBLUE(double & val)66 bool getBLUE( double& val ) const { return getBlueComponent( val ); } 67 68 bool getBlackComponent( double& val ) const; getBLCK(double & val)69 bool getBLCK( double& val ) const { return getBlackComponent( val ); } 70 71 //@} 72 73 /** 74 fill the given record based on the builder's object field/subfield 75 values -- return false if in a wedged state. (E.g., a mandatory 76 field isn't set or was assigned a value outside its proper 77 domain. 78 */ 79 bool getRecord( sc_Record& val ) const; 80 81 82 /** fills the given schema with one appropriate for CLRX 83 modules; returns false if unable to create the schema for some 84 bizarre reason. (Like maybe running out of memory.) Note that 85 an sio_Writer instance will need a schema generated from this 86 member. 87 */ 88 bool getSchema( sio_8211Schema& schema ) const; 89 90 91 /** set the object with values found in the record; if not a valid 92 CLRX record, this will return false 93 */ 94 bool setRecord( sc_Record const& val ); 95 96 97 //@{ 98 /** 99 Use these members to set subfield/field values. Pass in an appropriate 100 value for the particular subfield/field to be set to. They will return 101 false if you try to assign a value outside the domain of the given 102 subfield/field. (Note that this is not too pedantic; for example, we 103 do not check to see if a conditionally mandatory or optional field has 104 been set.) 105 */ 106 bool setRedComponent( double val ); setRED(double val)107 bool setRED( double val ) { return setRedComponent( val ); } 108 109 bool setGreenComponent( double val ); setGREN(double val)110 bool setGREN( double val ) { return setGreenComponent( val ); } 111 112 bool setBlueComponent( double val ); setBLUE(double val)113 bool setBLUE( double val ) { return setBlueComponent( val ); } 114 115 bool setBlackComponent( double val ); setBLCK(double val)116 bool setBLCK( double val ) { return setBlackComponent( val ); } 117 118 //@} 119 120 //@{ 121 /** 122 Since builder objects will be frequently 'recycled' (i.e., used for 123 more than one record), it might be convenient to 'unset' a previously 124 assigned value. So: 125 */ 126 127 void unDefineRedComponent( ); unDefineRED()128 void unDefineRED( ) { unDefineRedComponent( ); } 129 130 void unDefineGreenComponent( ); unDefineGREN()131 void unDefineGREN( ) { unDefineGreenComponent( ); } 132 133 void unDefineBlueComponent( ); unDefineBLUE()134 void unDefineBLUE( ) { unDefineBlueComponent( ); } 135 136 void unDefineBlackComponent( ); unDefineBLCK()137 void unDefineBLCK( ) { unDefineBlackComponent( ); } 138 139 //@} 140 141 private: 142 143 /// returns reference to schema 144 sio_8211Schema& schema_(); 145 146 147 /// 148 void buildSpecificSchema_(); 149 150 sb_Clrx(sb_Clrx const& right); // NOT NEEDED 151 sb_Clrx const& operator=(sb_Clrx const& right); // NOT NEEDED 152 153 154 sb_Clrx_Imp* _imp; 155 156 }; // sb_Clrx 157 158 159 #endif // INCLUDED_SB_CLRX_H 160 161