zMonitor Class Reference

#include <zMonitor.h>

Inheritance diagram for zMonitor:

Inheritance graph
[legend]
Collaboration diagram for zMonitor:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 zMonitor (eGrid *_grid)
 ~zMonitor ()
virtual void RemoveFromGame ()
 removes the object physically from the game
void setName (string name)
void addRule (zMonitorRulePtr aRule)
void setInit (tPolynomial< nMessage > v)
void setDrift (tPolynomial< nMessage > d)
void setClampLow (REAL l)
void setClampHigh (REAL h)
void affectSlide (gCycle *user, tPolynomial< nMessage > triggererInfluenceSlide, Triad marked)

Protected Member Functions

virtual bool Timestep (REAL currentTime)
 simulates behaviour up to currentTime

Protected Attributes

tPolynomial< nMessagetotalInfluence
 The sum of all the individual contributions in one, to be scaled in time.
triggerers contributors
 All the players that contributed to the sliding (ie proportional to time).
zMonitorRulePtrs rules
tPolynomial< nMessagevalueEq
tPolynomial< nMessagedrift
REAL minValue
 Low bound that value can take.
REAL maxValue
 High bound that value can take.
string name
tPolynomial< nMessagepreviousValue
tPolynomial< nMessagepreviousTotalInfluenceSlide


Detailed Description

Definition at line 27 of file zMonitor.h.


Constructor & Destructor Documentation

zMonitor::zMonitor ( eGrid _grid  )  [inline]

Definition at line 29 of file zMonitor.h.

References eGameObject::AddToList().

00029                            :
00030             eReferencableGameObject( _grid, eCoord( 1,1 ), eCoord( 0,0 ), NULL, true ),
00031             totalInfluence(0),
00032             contributors(),
00033             rules(),
00034             valueEq(),
00035             drift(0),
00036             minValue(0.0),
00037             maxValue(1.0),
00038             previousTotalInfluenceSlide(0)
00039     {
00040         // add to game grid
00041         this->AddToList();
00042     };

Here is the call graph for this function:

zMonitor::~zMonitor (  )  [inline]

Definition at line 44 of file zMonitor.h.

00044                 {
00045         //    contributors();
00046         //    rules();
00047     };


Member Function Documentation

virtual void zMonitor::RemoveFromGame ( void   )  [inline, virtual]

removes the object physically from the game

Reimplemented from eGameObject.

Definition at line 49 of file zMonitor.h.

References eGameObject::RemoveFromListsAll().

00049                                  {
00050         RemoveFromListsAll();
00051     };

Here is the call graph for this function:

void zMonitor::setName ( string  name  )  [inline]

Definition at line 53 of file zMonitor.h.

00053                               {
00054         this->name = name;
00055     };

void zMonitor::addRule ( zMonitorRulePtr  aRule  ) 

Definition at line 90 of file zMonitor.cpp.

References rules.

00090                                        {
00091     /*
00092      * HACK
00093      * This only works for a single rule! fix this
00094      */
00095     rules.push_back(aRule);
00096 }

void zMonitor::setInit ( tPolynomial< nMessage v  )  [inline]

Definition at line 58 of file zMonitor.h.

References valueEq.

00058                                           {
00059         valueEq = v;
00060     };

void zMonitor::setDrift ( tPolynomial< nMessage d  )  [inline]

Definition at line 61 of file zMonitor.h.

References drift.

00061                                            {
00062         drift = d;
00063     };

void zMonitor::setClampLow ( REAL  l  )  [inline]

Definition at line 64 of file zMonitor.h.

References minValue.

00064                               {
00065         minValue = l;
00066     };

void zMonitor::setClampHigh ( REAL  h  )  [inline]

Definition at line 67 of file zMonitor.h.

References maxValue.

00067                               {
00068         maxValue = h;
00069     };

void zMonitor::affectSlide ( gCycle user,
tPolynomial< nMessage triggererInfluenceSlide,
Triad  marked 
)

Definition at line 13 of file zMonitor.cpp.

References contributors, Triggerer::marked, totalInfluence, and Triggerer::who.

00013                                                                                           {
00014     Triggerer triggerer;
00015     triggerer.who = user;
00016     // TODO:
00017     //triggerer.positive = triggererInfluence > 0.0 ? _true : _false;
00018     triggerer.marked = marked;
00019 
00020     contributors.push_back(triggerer);
00021     totalInfluence += triggererInfluence;
00022 
00023 }

bool zMonitor::Timestep ( REAL  time  )  [protected, virtual]

simulates behaviour up to currentTime

Parameters:
time the current time

Reimplemented from eGameObject.

Definition at line 36 of file zMonitor.cpp.

References tPolynomial< T >::changeRate(), tPolynomial< T >::clamp(), contributors, drift, tPolynomial< T >::evaluate(), eGameObject::lastTime, tPolynomial< T >::Len(), maxValue, minValue, previousTotalInfluenceSlide, rules, totalInfluence, and valueEq.

00037 {
00038     tPolynomial<nMessage> prevValueEq = valueEq;
00039 
00040     if ( totalInfluence != previousTotalInfluenceSlide ) {
00041 
00042         for (int i=1; i<totalInfluence.Len(); i++) {
00043             valueEq.changeRate(totalInfluence[i], i, time);
00044         }
00045         // Set to null any remainding elements not reassigned in the previous loop
00046         for (int i=totalInfluence.Len(); i<valueEq.Len(); i++) {
00047             valueEq.changeRate(0.0, i, time);
00048         }
00049 
00050         previousTotalInfluenceSlide = totalInfluence;
00051     }
00052 
00053     valueEq = valueEq.clamp(minValue, maxValue, time);
00054 
00055     // Assemble all the contributors in a single list
00056     // Nota: this also protect the list for further modification
00057     // by recursives rules. Should all list be merged in a later version
00058     // still do make a copy at this step
00059 
00060 
00061     totalInfluence = drift;
00062 
00063     // Only update if value has changed enough
00064     // TODO:
00065     //    if( value < previousValue - EPS || previousValue + EPS < value) {
00066     // go through all the rules and find the ones to apply
00067     zMonitorRulePtrs::const_iterator iter;
00068     for (iter = rules.begin();
00069             iter != rules.end();
00070             ++iter)
00071     {
00072         // Go through all the rules of the monitor and see wich need to be activated
00073         if ((*iter)->isValid(valueEq.evaluate(time))) {
00074             (*iter)->applyRule(contributors, time, valueEq);
00075         }
00076     }
00077     //    }
00078 
00079     // Remove the information about who contributed in the last tic
00080     contributors.erase(contributors.begin(), contributors.end());
00081 
00082     // update time
00083     lastTime = time;
00084 
00085     return false;
00086 }

Here is the call graph for this function:


Member Data Documentation

tPolynomial<nMessage> zMonitor::totalInfluence [protected]

The sum of all the individual contributions in one, to be scaled in time.

Definition at line 74 of file zMonitor.h.

Referenced by affectSlide(), and Timestep().

triggerers zMonitor::contributors [protected]

All the players that contributed to the sliding (ie proportional to time).

Definition at line 78 of file zMonitor.h.

Referenced by affectSlide(), and Timestep().

zMonitorRulePtrs zMonitor::rules [protected]

Definition at line 80 of file zMonitor.h.

Referenced by addRule(), and Timestep().

tPolynomial<nMessage> zMonitor::valueEq [protected]

Definition at line 82 of file zMonitor.h.

Referenced by setInit(), and Timestep().

tPolynomial<nMessage> zMonitor::drift [protected]

Definition at line 83 of file zMonitor.h.

Referenced by setDrift(), and Timestep().

REAL zMonitor::minValue [protected]

Low bound that value can take.

Definition at line 85 of file zMonitor.h.

Referenced by setClampLow(), and Timestep().

REAL zMonitor::maxValue [protected]

High bound that value can take.

Definition at line 86 of file zMonitor.h.

Referenced by setClampHigh(), and Timestep().

string zMonitor::name [protected]

Definition at line 88 of file zMonitor.h.

tPolynomial<nMessage> zMonitor::previousValue [protected]

Definition at line 91 of file zMonitor.h.

tPolynomial<nMessage> zMonitor::previousTotalInfluenceSlide [protected]

Definition at line 92 of file zMonitor.h.

Referenced by Timestep().


The documentation for this class was generated from the following files:
Generated on Sun Mar 16 00:01:45 2008 for Armagetron Advanced by  doxygen 1.5.4