You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ryzom-core/code/ryzom/tools/assoc_mem/field.cpp

173 lines
4.7 KiB
C++

// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) 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 Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
/* Copyright, 2000 Nevrax Ltd.
*
* This file is part of NEVRAX NEL.
* NEVRAX NEL 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, or (at your option)
* any later version.
* NEVRAX NEL 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 NEVRAX NEL; see the file COPYING. If not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA.
*/
#include "field.h"
#include "cond_node.h"
CField::CField()
{
_Name = std::string("<unnamed>");
}
CField::CField(std::string name)
{
_Name = name;
}
const std::vector<IValue *> &CField::getPossibleValues() const
{
return _PossibleValues;
}
void CField::addPossibleValue(IValue *value)
{
_PossibleValues.push_back( value );
}
CField::~CField()
{
std::vector<IValue *>::iterator it_val = _PossibleValues.begin();
while ( ! _PossibleValues.empty() )
{
delete _PossibleValues.front();
_PossibleValues.erase( _PossibleValues.begin() );
}
}
const std::string &CField::getName() const
{
return _Name;
}
/////////////////////////////////////////////////////////////////////////////////////////////
CBoolField::CBoolField() : CField()
{
_PossibleValues.push_back( new CValue<bool>(true) );
_PossibleValues.push_back( new CValue<bool>(false) );
}
CBoolField::CBoolField(std::string name) : CField( name )
{
_PossibleValues.push_back( new CValue<bool>(true) );
_PossibleValues.push_back( new CValue<bool>(false) );
}
ICondNode *CBoolField::createNode(int key, int pos, std::vector<CRecord *> &)
{
ICondNode *node = new CEqualNode<bool>(this, pos);
return node;
}
/////////////////////////////////////////////////////////////////////////////////////////////
CStringField::CStringField() : CField()
{
}
CStringField::CStringField(std::string name, std::vector<std::string> &values) : CField(name)
{
std::vector<std::string>::iterator it_val = values.begin();
while ( it_val != values.end() )
{
_PossibleValues.push_back( new CValue<std::string>( *it_val ) );
it_val++;
}
}
ICondNode *CStringField::createNode(int key, int pos, std::vector<CRecord *> &)
{
return new CEqualNode<std::string>(this, pos);
}
/////////////////////////////////////////////////////////////////////////////////////////////
CIntField::CIntField() : CField()
{
}
CIntField::CIntField(std::string name, std::vector<int> &values) : CField( name )
{
std::vector<int>::iterator it_val = values.begin();
while ( it_val != values.end() )
{
_PossibleValues.push_back( new CValue<int>( *it_val ) );
it_val++;
}
}
ICondNode *CIntField::createNode(int key, int pos, std::vector<CRecord *> &)
{
return new CEqualNode<int>(this, pos);
}
/////////////////////////////////////////////////////////////////////////////////////////////
/*
CRealField::CRealField() : CField()
{
}
CRealField::CRealField(std::string name, std::vector<double> &values) : CField( name )
{
std::vector<double>::iterator it_val = values.begin();
while ( it_val != values.end() )
{
_PossibleValues.push_back( new CValue<double>( *it_val ) );
it_val++;
}
}
ICondNode *CRealField::createNode(int key, int pos, std::vector<CRecord *> &)
{
return new CEqualNode<int>(this, pos);
}
void CRealField::computeRanges(int key, int pos, std::vector<CRecord *> &records)
{
int max_gain_attrib = -1;
double max_gain = 0;
std::vector<CRecord *>::iterator it_r = records.begin();
while ( it_r != records.end() )
{
it_r++;
}
}
*/