/*
    TCFbEOutputCash.h    June 6, 2004.

    Copyright (C) 2003-2004 CFbE Research Group,
    Software Engineering Laboratory,
    Graduate School of Information Science,
    Nara Institute of Science and Technology,
    All rights reserved.

    This program is free software; you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2, (at your option) or
    any later version.

    This program is distributed in the hope that it will be useful, but
    WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with GNU Emacs; see the file COPYING.  If not, write to the
    Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/
//---------------------------------------------------------------------------
#ifndef TCFbEOutputCashH
#define TCFbEOutputCashH
//---------------------------------------------------------------------------
#include <system.hpp>
#include <Classes.hpp>
#include <stdio.h>
#include <Math.hpp>

#include "EDocfbeError.h"

#include "TCFbEDataSet.h"
#include "TCFbECommandLineParser.h"
#include "TCFbEDataLoader.h"

#include "TCFbETable.h"
//---------------------------------------------------------------------------
class TCFbEOutputCash : public TObject
{
public:
    virtual __fastcall TCFbEOutputCash(TCFbECommandLineParser* Parser, TCFbEDataLoader* DataLoader, bool IsVerbose=false);    // コンストラクタ
    __fastcall ~TCFbEOutputCash();    // デストラクタ

    virtual int __fastcall GetNumberOfRows(void) { return this->FResultTable->NumberOfRows; }
    virtual int __fastcall GetNumberOfColumns(void) { return this->FResultTable->NumberOfColumns; }

    virtual AnsiString __fastcall GetResultRowLabel(int RowIndex);
    virtual AnsiString __fastcall GetResultColumnLabel(int ColumnIndex);

    virtual bool __fastcall IsResultedColumn(int ColumnIndex) { return this->FIsResultedColumn[ColumnIndex]; }    // ColumnIndex 列目に結果が出力されているかどうかを調べる
    virtual bool __fastcall GetResultEnabled(int RowIndex, int ColumnIndex) { return this->FResultTable->CellsByIndex[RowIndex][ColumnIndex]->Enabled; }
    virtual double __fastcall GetResultValue(int RowIndex, int ColumnIndex) { return this->FResultTable->CellsByIndex[RowIndex][ColumnIndex]->Value; }
    virtual bool __fastcall GetResultFailed(int RowIndex, int ColumnIndex) { return this->FResultTable->CellsByIndex[RowIndex][ColumnIndex]->Rank == 0.0; }

    virtual int __fastcall GetNumberOfNeighbors(int TargetRowIndex) { return ((TObjectList*)this->FNeighborsList->Items[TargetRowIndex])->Count; }
    virtual TCFbENeighbor* __fastcall GetNeighbor(int TargetRowIndex, int NeighborsIndex) { return (TCFbENeighbor*)((TObjectList*)this->FNeighborsList->Items[TargetRowIndex])->Items[NeighborsIndex]; }
    virtual int __fastcall GetDistribution(int TargetRowIndex, int RangeIndex) { return (int)((TList*)this->FDistributionList->Items[TargetRowIndex])->Items[RangeIndex]; }

    int    ErrorCode;    // エラーコード（エラーがない場合は 0
    AnsiString    ErrorParameter;    // エラーパラメータ

protected:
    virtual void __fastcall CountDistribution(TCFbEDataSet* DataSet, int TargetRowIndex, TList* StoredList);    // DataSet における TargetRowIndex 行目の行に対する類似度の分布を StoredList に格納して返す

    TCFbECommandLineParser*    Parser;
    TCFbEDataLoader*    DataLoader;
    TCFbETable*    FResultTable;    // 計算結果を格納するテーブル
    TObjectList*    FNeighborsList;    // NearestNeighbors を格納する TObjectList を格納するための TObjectList
    TObjectList*    FDistributionList;    // 類似度の分布を格納する TList を格納するための TObjectList
    TBooleanDynArray    FIsResultedColumn;    // 各列に出力された値があるか

private:

};
//---------------------------------------------------------------------------
#endif
