/****************************************************************************
                Validation Class
                -----------------------------------------
    begin      : 2014/09/02
    copyright  : (C) 2005 Solbox Inc.
    author     : Storage Dev Team	                
    email      : storage.sd@solbox.com
    version    : 3.4

    CopyRight(C) 2005 Solbox Inc. All Rights reserved.
    Redistribution and use in source and binary forms, with or with out
    modification, are not permitted in outside of Solbox Inc.
*****************************************************************************/

#ifndef __VALIDATION_H__
#define __VALIDATION_H__

#include <vector>

# if __GNUC__ >= 3
#   include <ext/hash_map>
using namespace __gnu_cxx;
# else
#   include <hash_map>
# endif

#include "SyncList.h"
#include "Database.h"

struct hash_key2
{
	size_t operator() (const string &k) const
	{
		return __stl_hash_string(k.c_str());
	}
};
struct compare_key2
{
	bool operator () (const string s1, const string &s2) const
	{
		return s1 == s2;
	}
};

typedef hash_multimap<string, vector<string>, hash_key2, compare_key2> CCurretMap;

class CValidation
{
public:
	CValidation(CSyncInfo& info, string data);
	~CValidation();
	
	// diff 된 데이터 검증
	bool	CheckValidation(bool is_master = true);

private:
	// 현재 meta에서 input된 uri, hash에 대한 최신 상태 가져오기 
	bool	GetCurrentMeta(DataBase* db, vector<string> & vectdiff, string &tblname, string &tran_id, bool useDisyplay);
	
	// input 된 데이터와 현재 meta 데이터 비교
	// sync file로 저장될 데이터를 리턴한다. 
	vector<string>  CompareData(vector<string> & vectdiff, string &tran_id);
		
	// outdata 를 sync file formate 맞게 쓰기함
	bool WriteSyncFile(vector<string>& outdata);
	
	// filename_hash 리턴
	string GetFullFilenameHash(vector<string> & vectdiff, string &tran_id);
	
	CSyncInfo	m_syncinfo;
	string		m_diffdata;

	CCurretMap	m_current;
};

#endif /* __VALIDATION_H__ */
