#ifndef ACCOUNTFILE_H_
#define ACCOUNTFILE_H_

// Author: Steve Talbot

#pragma once

using namespace std;

#include "AccountInfo.h"
#include <iostream>
#include <fstream>
#include <string>
#include <map>

class AccountFile {

public:
	AccountFile();
	~AccountFile();

	int findAccountInfoPageID( int id_, fstream* file_ );
	bool hasAccountInfo( int id_ );
	bool loadAccountInfoFromFile( int id_ );
	bool writeAccountInfoToFile();

	// getters ..
	AccountInfo* getAccountInfo();
	string getFileDrive();
	string getFileDirectory();
	string getFileName();

	// setters ..
	void setAccountInfo( AccountInfo* accountInfo_ );
	void setFileDrive( string fileDrive_ );
	void setFileDirectory( string fileDirectory_ );
	void setFileName( string fileName_ );

	// utility methods ..
	int findPageID( int id_ );
	void addUserId_PageID_Pair( int id_, int pageID_ );

private:

	AccountInfo* _accountInfo;

	map<int, int>* _userID_PageID_Pairs;

	string _fileDrive;		// i.e.: "C:\\" ..

	string _fileDirectory;	// i.e.: "Temp\\" ..

	string _fileName;		// includes extension: i.e. "Bank_Accounts.bin" ..

	// size of each "int" field in a record / "block" in the file ..
	int _intSize;

	// size of each "bool" field in a record / "block" in the file ..
	int _boolSize;

	// size of each account record / "block" in the file ..
	int _blockSize;

};

#endif /*ACCOUNTFILE_H_*/
