#include <retinalobjs.h>
Inheritance diagram for Retinal_Object:
The interface is very fat, supplying many operations that have proven useful in practice, but which are not strictly required.
Although it is abstract and cannot be instantiated, this class is actually fairly concrete, supplying implementations for nearly all operations. A derived class need only provide activ() and clone() to be complete. Most will also override update() to handle values needed to be cached for activ() to use quickly, and some may override other virtual functions.
The parameters are primarily ValueGenerator types; these are all passed in a map for convenience in object creation and to make it easier to manage next() and reset() of those variables. The current values of those variables may be cached internally by a call to update(). To ensure the coherence of this cache, update() should be called before calling activation(), after any ValueGenerator might have changed its value. Ordinarily this is achieved by calling update() just before a series of calls to activation().
No assignment operator is defined yet.
Definition at line 75 of file retinalobjs.h.
Quasi-protected members. | |
These members would otherwise be marked 'protected', but a Retinal_Composite object needs to be able to access them.
A composite object is not necessarily (or even usually) the same type as the objects it contains, and an obscure C++ rule stipulates that a class can only access protected members of objects of its own specific type. Thus even though these members are nominally public, only derived classes should use them. | |
virtual Activity | default_activation () const |
As activation() is to activ(), this is to default_activ(). | |
BBox | bounding_box |
Bounding box enclosing this object in the plane. | |
Public Types | |
typedef double | Variable |
Underlying type for a ValueGenerator variable. | |
typedef ValueGenerator< Variable > | VarGen |
Type of ValueGenerator to use for variables. | |
typedef ValueGeneratorMap< Variable > | VarMap |
Type of ValueGenerator map to use to hold variables. | |
Public Methods | |
Constructors and destructors | |
Retinal_Object (const string &name_val, const VarMap &init_vars=VarMap()) | |
Retinal_Object (const Retinal_Object &b) | |
Primary Interface | |
If a derived class overrides one of these virtual functions, it should call this base-class version when it is done. | |
virtual bool | next () |
Advance to the next state (whatever that means for this object). | |
virtual void | reset () |
Reset to the starting state. | |
virtual bool | update () const |
Must be called just before calling activation() one or more times. | |
virtual Activity | activation (Coordinate x, Coordinate y) const |
Returns the activation at a given set of coordinates. | |
Other functions which may be useful | |
virtual string | stringrep () const |
(Partial) representation of this object's state as a string | |
virtual Retinal_Object * | clone () const=0 |
Return an identical copy of this object allocated from the heap. | |
virtual void | relink (const Retinal_Object *master) |
Replace all Variables with those in the specified object. | |
bool | get_active () const |
Query whether the object is currently displayed. | |
void | set_active (bool whether_active) |
Set whether the object is currently displayed. | |
const string & | name () const |
Query name string. | |
const string & | get_name () const |
void | set_name (const string &newname) |
Set name string. | |
const Variable | get_var (const string &varname) const |
Query a parameter. | |
Variable * | get_varptr (const string &varname) |
Deprecated: get a pointer to the actual parameter storage location. | |
string | vargen_stringrep (const string &varname) const |
Returns a string representation of the specified VarGen, if found. | |
virtual const Retinal_Composite * | get_parent () const |
If this object stores a pointer to its parent, return it. | |
virtual void | set_parent (const Retinal_Composite *_parentptr) |
Store a pointer to our parent. | |
virtual Angle | angle () const |
Query current angle for this object. | |
virtual Retinal_Object * | find (const string &othername) |
Find by name; see Retinal_Composite::find() for more info. | |
void | merge_vars (const VarMap &init_vars) |
For use in complicated constructors: set a lot of variables at once. | |
virtual bool | inside (Coordinate x, Coordinate y) const |
Returns true if the given coordinate is inside the active area of this object, favoring the most precise response possible, regardless of performance. | |
Protected Types | |
typedef AARBoundingBox< Coordinate > | BBox |
Concrete type of bounding box to use. | |
Protected Methods | |
const void | set_var_default (const string &varname, Variable val) |
Set a parameter only if not yet set; accepts only a variable, not a generator. | |
Friends | |
class | DefaultActivityAccumulator |
|
Returns the activation at a given set of coordinates. Must call update() just before this, though multiple activation() calls in a row are fine. Implements Retinal_Obj. Reimplemented in Retinal_RandomNoise< RandomGen >. Definition at line 131 of file retinalobjs.h. References Retinal_Obj::Activity, and bounding_box. Referenced by Retinal_Composite::mostactive(), and ActivityAccumulator::operator()(). |
|
Returns true if the given coordinate is inside the active area of this object, favoring the most precise response possible, regardless of performance. A rectangular bounding box will suffice, but if an object can give a more precise answer, e.g. if it really has a circular or irregular shape instead of a box, it should give the more precise answer here. This call should be used only when such precision is needed; the regular rectangular bounding box can be used in other cases. Reimplemented in Retinal_Composite, and Retinal_PGM. Definition at line 202 of file retinalobjs.h. References bounding_box. Referenced by Retinal_Composite::inside(), and ActivityAccumulator::operator()(). |
|
Returns a string representation of the specified VarGen, if found. Deprecated, because it relies on obtaining the underlying VarGen type from the VarMap, but useful for debugging. Definition at line 170 of file retinalobjs.h. References ValueGeneratorMap< Variable >::getvalgenptr(), and ValueGenerator< T >::stringrep(). |