Correct templatized types across ObjectiveVector-dependant code

This commit is contained in:
Johann Dreo 2013-06-07 11:52:50 +02:00
commit 818425565d
4 changed files with 13 additions and 11 deletions

View file

@ -33,17 +33,19 @@ Authors:
#include <comparator/moeoObjectiveObjectiveVectorComparator.h>
#include <comparator/moeoParetoObjectiveVectorComparator.h>
#include <core/moeoRealObjectiveVector.h>
#include <core/moeoScalarObjectiveVector.h>
template < class ObjectiveVectorTraits >
class moeoDualRealObjectiveVector : public moeoScalarObjectiveVector<ObjectiveVectorTraits, eoMinimizingDualFitness >
template < class ObjectiveVectorTraits, class T = eoMinimizingDualFitness /* can be an eoMaximizingDualFitness */>
class moeoDualRealObjectiveVector : public moeoScalarObjectiveVector<ObjectiveVectorTraits, T >
{
protected:
bool _is_feasible;
public:
moeoDualRealObjectiveVector(double value=0.0) : moeoScalarObjectiveVector<ObjectiveVectorTraits, eoMinimizingDualFitness >(value, false) {}
moeoDualRealObjectiveVector(double value=0.0)
: moeoScalarObjectiveVector<ObjectiveVectorTraits, eoMinimizingDualFitness >
( T(value, false) ) {}
bool is_feasible() const
{

View file

@ -151,8 +151,8 @@ class moeoScalarObjectiveVector : public moeoObjectiveVector < ObjectiveVectorTr
* @param _os output stream
* @param _objectiveVector the objective vector to write
*/
template < class ObjectiveVectorTraits >
std::ostream & operator<<(std::ostream & _os, const moeoScalarObjectiveVector < ObjectiveVectorTraits > & _objectiveVector)
template < class ObjectiveVectorTraits, class T >
std::ostream & operator<<(std::ostream & _os, const moeoScalarObjectiveVector < ObjectiveVectorTraits, T > & _objectiveVector)
{
for (unsigned int i=0; i<_objectiveVector.size()-1; i++)
_os << _objectiveVector[i] << " ";
@ -165,10 +165,10 @@ std::ostream & operator<<(std::ostream & _os, const moeoScalarObjectiveVector <
* @param _is input stream
* @param _objectiveVector the objective vector to read
*/
template < class ObjectiveVectorTraits >
std::istream & operator>>(std::istream & _is, moeoScalarObjectiveVector < ObjectiveVectorTraits > & _objectiveVector)
template < class ObjectiveVectorTraits, class T >
std::istream & operator>>(std::istream & _is, moeoScalarObjectiveVector < ObjectiveVectorTraits, T > & _objectiveVector)
{
_objectiveVector = moeoScalarObjectiveVector < ObjectiveVectorTraits > ();
_objectiveVector = moeoScalarObjectiveVector < ObjectiveVectorTraits, T > ();
for (unsigned int i=0; i<_objectiveVector.size(); i++)
{
_is >> _objectiveVector[i];