This repository has been archived on 2026-03-28. You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
eodev/eo/src/eoOpSelector.h
gustavo 3fe0218a72
1999-01-29 12:23:55 +00:00

68 lines
2.2 KiB
C++

// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
//-----------------------------------------------------------------------------
// eoOpSelector.h
// (c) GeNeura Team 1998
//-----------------------------------------------------------------------------
#ifndef EOOPSELECTOR_H
#define EOOPSELECTOR_H
//-----------------------------------------------------------------------------
#include <stdexcept> // runtime_error
#include <eoObject.h>
#include <eoPrintable.h>
#include <eoOp.h>
//-----------------------------------------------------------------------------
/** An operator selector is an object that contains a set of EO operators, and
and selects one based on whatever criteria. It will be used in the breeder objects.\\
This class is basically a generic interface for operator selection
*/
template<class EOT>
class eoOpSelector: public eoObject, public eoPrintable
{
public:
typedef unsigned ID;
/** add an operator to the operator set
@param _op a genetic operator, that will be applied in some way
@param _arg the operator rate, usually, or any other argument to the operator
@return an ID that will be used to identify the operator
*/
virtual ID addOp( eoOp<EOT>& _op, float _arg ) = 0;
/** Gets a non-const reference to an operator, so that it can be changed,
modified or whatever
@param _id a previously assigned ID
@throw runtime_exception if the ID does not exist*/
virtual eoOp<EOT>& getOp( ID _id ) = 0;
/** Remove an operator from the operator set
@param _id a previously assigned ID
@throw runtime_exception if the ID does not exist
*/
virtual deleteOp( ID _id ) = 0;
/// Returns a genetic operator according to the established criteria
virtual const eoOp<EOT>& Op() = 0;
/// Methods inherited from eoObject
//@{
/** Return the class id.
@return the class name as a string
*/
virtual string className() const { return "eoOpSelector"; };
/**
* Read object and print objects are left for subclasses to define.
*/
//@}
};
//-----------------------------------------------------------------------------
#endif EO_H