Show
Ignore:
Timestamp:
04/09/10 09:31:37 (14 years ago)
Author:
mido
Message:

cleanup of MemDS and its descendants
bdmtoolbox/CMakeLists.txt slightly changed to avoid unnecessary MEX condition
"indeces" replaced by "indices"

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • library/bdm/base/datasources.h

    r895 r896  
    3232        //! active column in the Data matrix 
    3333        int time; 
    34         //!  vector of rows that are presented in Dt 
    35         ivec rowid; 
    36  
    37 public: 
     34 
     35public: 
     36        //!Default constructor 
     37        MemDS () {}; 
     38 
     39        //! Convenience constructor 
     40        MemDS ( mat &Dat ); 
     41 
     42        //! returns number of data in the file; 
    3843        int max_length() { 
    3944                return Data.cols(); 
    4045        } 
     46 
    4147        void getdata ( vec &dt ) const; 
    42         void getdata ( vec &dt, const ivec &indeces ); 
    43         void set_drv ( const RV &drv, const  RV &urv ); 
     48 
     49        void getdata ( vec &dt, const ivec &indices ); 
     50 
     51        void set_drv ( const RV &drv ); 
     52 
     53        void set_drv ( const RV &drv, const RV &urv ) 
     54        { 
     55                bdm_error ( "MemDS::urv is not supported" ); 
     56        } 
    4457 
    4558        void write ( const vec &ut ) { 
     
    5265 
    5366        void step(); 
    54         //!Default constructor 
    55         MemDS () {}; 
    56         //! Convenience constructor 
    57         MemDS ( mat &Dat, ivec &rowid0 ); 
     67 
    5868        /*! Create object from the following structure 
    5969        \code 
     
    6373           drv = {class="RV"; ...} // Identification how rows of the matrix Data will be known to others 
    6474           time = 0;               // Index of the first column to user_info, 
    65            rowid = [1,2,3...];     // ids of rows to be used 
    6675        } 
    6776        \endcode 
     
    6978        If the optional fields are not given, they will be filled as follows: 
    7079        \code 
    71         rowid= [0, 1, 2, ...number_of_rows_of_Data]; 
    7280        drv = {names=("ch0", "ch1", "ch2", ..."number_of_rows_of_Data"); 
    7381              sizes=( 1    1    1 ...); 
     
    7684        time = 0; 
    7785        \endcode 
    78         If \c rowid is given, \c drv will be named after indeces in rowids. 
     86        If \c rowid is given, \c drv will be named after indices in rowids. 
    7987 
    8088        Hence the data provided by method \c getdata() will be full column of matrix Data starting from the first record. 
    8189        */ 
    82         void from_setting ( const Setting &set ) { 
    83                 UI::get ( Data, set, "Data", UI::compulsory ); 
    84                 if ( !UI::get ( time, set, "time", UI::optional ) ) { 
    85                         time = 0; 
    86                 } 
    87                 if ( !UI::get ( rowid, set, "rowid", UI::optional ) ) { 
    88                         rowid = linspace ( 0, Data.rows() - 1 ); 
    89                 } 
    90                 shared_ptr<RV> r = UI::build<RV> ( set, "drv", UI::optional ); 
    91                 if ( !r ) { 
    92                         r = new RV(); 
    93                         for ( int i = 0; i < rowid.length(); i++ ) { 
    94                                 r->add ( RV ( "ch" + num2str ( rowid ( i ) ), 1, 0 ) ); 
    95                         } 
    96                 } 
    97                 set_drv ( *r, RV() ); //empty urv 
    98                 dtsize = r->_dsize(); 
    99                 utsize = 0; 
    100         } 
     90        void from_setting ( const Setting &set ); 
    10191}; 
    10292UIREGISTER ( MemDS ); 
     
    10696*/ 
    10797class FileDS: public MemDS { 
    108  
    109 public: 
    110         void getdata ( vec &dt ) { 
    111                 dt = Data.get_col ( time ); 
    112         } 
    113  
    114         void getdata ( vec &dt, const ivec &indices ) { 
    115                 vec tmp = Data.get_col ( time ); 
    116                 dt = tmp ( indices ); 
    117         } 
    118  
    119         //! returns number of data in the file; 
    120         int ndat() { 
    121                 return Data.cols(); 
    122         } 
    123         //! no sense to log this type 
    124         void log_register ( logger &L, const string &prefix ) {}; 
    125         //! no sense to log this type 
    126         void log_write ( ) const {}; 
     98protected: 
     99        string filename; 
     100public: 
     101        void from_setting ( const Setting & set ); 
    127102}; 
    128103 
     
    142117                it >> Data; 
    143118                time = 0; 
    144                 //rowid and delays are ignored 
     119                //delays are ignored 
    145120        }; 
    146121 
     
    165140*/ 
    166141class CsvFileDS: public FileDS { 
    167  
    168 public: 
    169         //! Constructor - create DS from a CSV file. 
    170         CsvFileDS ( const string& fname, const string& orientation = "BY_COL" ); 
     142public: 
     143        void from_setting ( const Setting & set ); 
    171144}; 
    172145 
     
    203176        virtual void write ( const vec &ut ) NOT_IMPLEMENTED_VOID; 
    204177 
    205         //! Accepts action variables at specific indeces 
    206         virtual void write ( const vec &ut, const ivec &indeces ) NOT_IMPLEMENTED_VOID; 
     178        //! Accepts action variables at specific indices 
     179        virtual void write ( const vec &ut, const ivec &indices ) NOT_IMPLEMENTED_VOID; 
    207180 
    208181        /*! 
     
    261234 
    262235 
    263         //! Returns data records at indeces. 
    264         virtual void getdata ( vec &dt, const ivec &indeces ) NOT_IMPLEMENTED_VOID; 
     236        //! Returns data records at indices. 
     237        virtual void getdata ( vec &dt, const ivec &indices ) NOT_IMPLEMENTED_VOID; 
    265238 
    266239 
     
    364337        } 
    365338 
    366         virtual void write ( const vec &ut, const ivec &indeces ) NOT_IMPLEMENTED_VOID; 
     339        virtual void write ( const vec &ut, const ivec &indices ) NOT_IMPLEMENTED_VOID; 
    367340 
    368341        /*! UI for stateDS