00001 #ifndef rgrl_feature_reader_h_ 00002 #define rgrl_feature_reader_h_ 00003 00004 //: 00005 // \file 00006 // \author Gehua Yang 00007 // Smart reader to read in any feature 00008 // \verbatim 00009 // Modifications 00010 // Nov 2008 - J Becker - Added a class width a static read function based on rgrl_trans_reader. 00011 // This is to allow user to add other local-defined feature types. For 00012 // backward compatibility I left the original read function. 00013 // \endverbatim 00014 00015 #include <rgrl/rgrl_feature_sptr.h> 00016 00017 #include <vcl_iosfwd.h> 00018 #include <vcl_vector.h> 00019 00020 //: Read one feature from input stream 00021 // IMPORTANCE: 00022 // - Open text file in BINARY mode! 00023 // - Stream Pos does not work in Windows when a UNIX ascii file is opened in text mode. 00024 // 00025 00026 00027 //: Reader class for smartly detecting various transformation classes 00028 // Users can also add user-defined classes, which takes priority before others 00029 class rgrl_feature_reader 00030 { 00031 public: 00032 00033 //: Read a transformation from input stream 00034 // IMPORTANCE: 00035 // - Open transformation file in BINARY mode! 00036 // - Stream Pos does not work in Windows when a UNIX ascii file 00037 // is opened in text mode. 00038 // 00039 // The type of feature depends on the content of the input stream. 00040 // NULL smart ptr is returned if reading operation fails. 00041 // Please check the validity of the returned smart ptr. 00042 static 00043 rgrl_feature_sptr read( vcl_istream& is ); 00044 00045 //: add a feature candidate 00046 static 00047 void add_feature( rgrl_feature_sptr feat ); 00048 00049 protected: 00050 static vcl_vector< rgrl_feature_sptr > feature_candidates_; 00051 }; 00052 00053 //: The type of feature depends on the content of the input stream. 00054 // NULL smart ptr is returned if the reading operation fails. 00055 // Please check the validity of the returned smart ptr. 00056 rgrl_feature_sptr 00057 rgrl_feature_reader( vcl_istream& is ); 00058 00059 //: stream input operator for reading a feature 00060 vcl_istream& operator>>( vcl_istream& is, rgrl_feature_sptr& sptr ); 00061 00062 #endif // rgrl_feature_reader_h_