Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// Params.h: interface for the CParams class.
Toshihiro Shimizu 890ddd
//
Toshihiro Shimizu 890ddd
//////////////////////////////////////////////////////////////////////
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#if !defined(AFX_PARAMS_H__40D9A921_F329_11D5_B92E_0040F674BE6A__INCLUDED_)
Toshihiro Shimizu 890ddd
#define AFX_PARAMS_H__40D9A921_F329_11D5_B92E_0040F674BE6A__INCLUDED_
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#if _MSC_VER > 1000
Toshihiro Shimizu 890ddd
#pragma once
Toshihiro Shimizu 890ddd
#endif // _MSC_VER > 1000
Toshihiro Shimizu 890ddd
Shinya Kitaoka 9f5a1b
#ifdef _WIN32
Toshihiro Shimizu 890ddd
#include "Windows.h"
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
#include <fstream></fstream>
Toshihiro Shimizu 890ddd
#include <vector></vector>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "InputParam.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#define P(d) tmsg_info(" - %d -\n", d)
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
template <class eparam=""></class>
Toshihiro Shimizu 890ddd
class CParams
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 2148c8
	std::vector<eparam> m_params;</eparam>
Toshihiro Shimizu 890ddd
	double m_scale;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	CParams() : m_params(0), m_scale(1.0){};
Toshihiro Shimizu 890ddd
	CParams(const CParams &cp) : m_params(cp.m_params),
Toshihiro Shimizu 890ddd
								 m_scale(cp.m_scale){};
Toshihiro Shimizu 890ddd
	virtual ~CParams(){};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	CParams(const CInputParam &ip) : m_scale(ip.m_scale)
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		if (ip.m_isEconf) {
Toshihiro Shimizu 890ddd
			//read(ip.m_econfFN);
Toshihiro Shimizu 890ddd
		} else {
Toshihiro Shimizu 890ddd
			m_params.resize(1);
Toshihiro Shimizu 890ddd
			m_params[0].read(ip);
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
	/*
Toshihiro Shimizu 890ddd
void print() 
Toshihiro Shimizu 890ddd
{	char s[1024];
Toshihiro Shimizu 890ddd
	int i;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	OutputDebugString("===== PARAMS =====\n");
Toshihiro Shimizu 890ddd
	sprintf(s,"Scale=%f\n",m_scale);
Toshihiro Shimizu 890ddd
	OutputDebugString(s);
Toshihiro Shimizu 890ddd
	i=0;
Toshihiro Shimizu 890ddd
	for( vector<eparam>::iterator p=m_params.begin(); </eparam>
Toshihiro Shimizu 890ddd
		p!=m_params.end(); ++p,++i ){
Toshihiro Shimizu 890ddd
		sprintf(s,"--- %d. Param ---\n",i);
Toshihiro Shimizu 890ddd
		OutputDebugString(s);
Toshihiro Shimizu 890ddd
		p->print();
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
	OutputDebugString("==================\n");
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
*/
Toshihiro Shimizu 890ddd
	/*
Toshihiro Shimizu 890ddd
void read(const basic_string<char>& name)</char>
Toshihiro Shimizu 890ddd
{	basic_ifstream<char> in(name.c_str());</char>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	for( bool isOK=true; isOK; ) { 
Toshihiro Shimizu 890ddd
		m_params.resize(m_params.size()+1);
Toshihiro Shimizu 890ddd
		vector<eparam>::iterator p=m_params.end();</eparam>
Toshihiro Shimizu 890ddd
		p--;
Toshihiro Shimizu 890ddd
		isOK=p->read(in);
Toshihiro Shimizu 890ddd
		if ( !isOK ) 
Toshihiro Shimizu 890ddd
			m_params.resize(m_params.size()-1);
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
	in.close();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
*/
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void scale(const double sc)
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		for (int i = 0; i < m_params.size(); ++i)
Toshihiro Shimizu 890ddd
			m_params[i]->scale(sc);
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void scale()
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		for (int i = 0; i < m_params.size(); ++i)
Toshihiro Shimizu 890ddd
			m_params[i]->scale(m_scale);
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#endif // !defined(AFX_PARAMS_H__40D9A921_F329_11D5_B92E_0040F674BE6A__INCLUDED_)