#ifndef __DYNAREL_H
#define __DYNAREL_H

#ifndef __ISAM_H
#include <isam.h>
#endif

#ifndef __ASSOC_H
#include <assoc.h>
#endif

#ifndef __UTILITY_H
#include <utility.h>
#endif

#include <stdlib.h>

#define MAX_FILES             100

class TField_array : public TAssoc_array
{
  public:
     
    const TString& get( const TString& nome_campo );
    int get_int( const TString& nome_campo );
    long get_long( const TString& nome_campo );
    bool get_bool( const TString& nome_campo );
    real get_real( const TString& nome_campo );
    
    TField_array( const TRectype& rec );    
      
};

class TDyna_rel : public TObject
{
  private:
    
    int _main_file;
    TArray  _file_array;
    TString_array _rules;
    int _keys[ MAX_FILES ];
    
  protected:
  
    bool file_added( const int file_index );
    bool file_loaded( const int file_index );
    void load_file( const int file_index );
   
  public:
    
    TDyna_rel( const int main_file_index );
    void add_file( const int file_index, const TToken_string rule, const int key );
    
    TField_array& file( const int file_index ){ return (  TField_array& )_file_array[ file_index ]; };
    const TString& get( const int file_index, const TString16 nome_campo );
    int get_int( const int file_index, const TString16 nome_campo );
    long get_long( const int file_index, const TString16 nome_campo );
    bool get_bool( const int file_index, const TString16 nome_campo );
    real get_real( const int file_index, const TString16 nome_campo );

};

#endif
