Commit 0b62586c authored by Clément Stenac's avatar Clément Stenac

Support for passing an argument from subject to observer

parent 4eed3209
...@@ -131,7 +131,7 @@ void CtrlButton::setImage( AnimBitmap *pImg ) ...@@ -131,7 +131,7 @@ void CtrlButton::setImage( AnimBitmap *pImg )
} }
void CtrlButton::onUpdate( Subject<AnimBitmap> &rBitmap ) void CtrlButton::onUpdate( Subject<AnimBitmap, void*> &rBitmap, void *arg )
{ {
notifyLayout(); notifyLayout();
} }
......
...@@ -34,7 +34,7 @@ class CmdGeneric; ...@@ -34,7 +34,7 @@ class CmdGeneric;
/// Base class for button controls /// Base class for button controls
class CtrlButton: public CtrlGeneric, public Observer<AnimBitmap> class CtrlButton: public CtrlGeneric, public Observer<AnimBitmap, void*>
{ {
public: public:
/// Create a button with 3 images /// Create a button with 3 images
...@@ -88,7 +88,7 @@ class CtrlButton: public CtrlGeneric, public Observer<AnimBitmap> ...@@ -88,7 +88,7 @@ class CtrlButton: public CtrlGeneric, public Observer<AnimBitmap>
void setImage( AnimBitmap *pImg ); void setImage( AnimBitmap *pImg );
/// Method called when an animated bitmap changes /// Method called when an animated bitmap changes
virtual void onUpdate( Subject<AnimBitmap> &rBitmap ); virtual void onUpdate( Subject<AnimBitmap, void*> &rBitmap, void* );
}; };
......
...@@ -155,7 +155,7 @@ bool CtrlGeneric::isVisible() const ...@@ -155,7 +155,7 @@ bool CtrlGeneric::isVisible() const
} }
void CtrlGeneric::onUpdate( Subject<VarBool> &rVariable ) void CtrlGeneric::onUpdate( Subject<VarBool, void*> &rVariable, void *arg )
{ {
// Is it the visibility variable ? // Is it the visibility variable ?
if( &rVariable == m_pVisible ) if( &rVariable == m_pVisible )
......
...@@ -41,7 +41,7 @@ class VarBool; ...@@ -41,7 +41,7 @@ class VarBool;
/// Base class for controls /// Base class for controls
class CtrlGeneric: public SkinObject, public Observer<VarBool> class CtrlGeneric: public SkinObject, public Observer<VarBool, void*>
{ {
public: public:
virtual ~CtrlGeneric(); virtual ~CtrlGeneric();
...@@ -128,7 +128,7 @@ class CtrlGeneric: public SkinObject, public Observer<VarBool> ...@@ -128,7 +128,7 @@ class CtrlGeneric: public SkinObject, public Observer<VarBool>
VarBool *m_pVisible; VarBool *m_pVisible;
/// Method called when an observed bool variable is changed /// Method called when an observed bool variable is changed
virtual void onUpdate( Subject<VarBool> &rVariable ); virtual void onUpdate( Subject<VarBool, void*> &rVariable , void* );
}; };
typedef CountedPtr<CtrlGeneric> CtrlGenericPtr; typedef CountedPtr<CtrlGeneric> CtrlGenericPtr;
......
...@@ -72,14 +72,14 @@ CtrlList::~CtrlList() ...@@ -72,14 +72,14 @@ CtrlList::~CtrlList()
} }
void CtrlList::onUpdate( Subject<VarList> &rList ) void CtrlList::onUpdate( Subject<VarList, void*> &rList, void *arg )
{ {
autoScroll(); autoScroll();
m_pLastSelected = NULL; m_pLastSelected = NULL;
} }
void CtrlList::onUpdate( Subject<VarPercent> &rPercent ) void CtrlList::onUpdate( Subject<VarPercent, void*> &rPercent, void *arg )
{ {
// Get the size of the control // Get the size of the control
const Position *pPos = getPosition(); const Position *pPos = getPosition();
......
...@@ -35,8 +35,8 @@ class GenericBitmap; ...@@ -35,8 +35,8 @@ class GenericBitmap;
/// Class for control list /// Class for control list
class CtrlList: public CtrlGeneric, public Observer<VarList>, class CtrlList: public CtrlGeneric, public Observer<VarList, void*>,
public Observer<VarPercent> public Observer<VarPercent, void *>
{ {
public: public:
CtrlList( intf_thread_t *pIntf, VarList &rList, CtrlList( intf_thread_t *pIntf, VarList &rList,
...@@ -88,10 +88,10 @@ class CtrlList: public CtrlGeneric, public Observer<VarList>, ...@@ -88,10 +88,10 @@ class CtrlList: public CtrlGeneric, public Observer<VarList>,
int m_lastPos; int m_lastPos;
/// Method called when the list variable is modified /// Method called when the list variable is modified
virtual void onUpdate( Subject<VarList> &rList ); virtual void onUpdate( Subject<VarList, void*> &rList, void* );
/// Method called when the position variable of the list is modified /// Method called when the position variable of the list is modified
virtual void onUpdate( Subject<VarPercent> &rPercent ); virtual void onUpdate( Subject<VarPercent, void*> &rPercent, void* );
/// Called when the position is set /// Called when the position is set
virtual void onPositionChange(); virtual void onPositionChange();
......
...@@ -98,7 +98,8 @@ void CtrlRadialSlider::draw( OSGraphics &rImage, int xDest, int yDest ) ...@@ -98,7 +98,8 @@ void CtrlRadialSlider::draw( OSGraphics &rImage, int xDest, int yDest )
} }
void CtrlRadialSlider::onUpdate( Subject<VarPercent> &rVariable ) void CtrlRadialSlider::onUpdate( Subject<VarPercent,void*> &rVariable,
void *arg )
{ {
m_position = (int)( m_rVariable.get() * m_numImg ); m_position = (int)( m_rVariable.get() * m_numImg );
notifyLayout( m_width, m_height ); notifyLayout( m_width, m_height );
......
...@@ -36,7 +36,7 @@ class VarPercent; ...@@ -36,7 +36,7 @@ class VarPercent;
/// Radial slider /// Radial slider
class CtrlRadialSlider: public CtrlGeneric, public Observer<VarPercent> class CtrlRadialSlider: public CtrlGeneric, public Observer<VarPercent, void*>
{ {
public: public:
/// Create a radial slider with the given image, which must be /// Create a radial slider with the given image, which must be
...@@ -86,7 +86,7 @@ class CtrlRadialSlider: public CtrlGeneric, public Observer<VarPercent> ...@@ -86,7 +86,7 @@ class CtrlRadialSlider: public CtrlGeneric, public Observer<VarPercent>
DEFINE_CALLBACK( CtrlRadialSlider, Move ) DEFINE_CALLBACK( CtrlRadialSlider, Move )
/// Method called when the observed variable is modified /// Method called when the observed variable is modified
virtual void onUpdate( Subject<VarPercent> &rVariable ); virtual void onUpdate( Subject<VarPercent,void*> &rVariable, void* );
/// Change the position of the cursor, with the given position of /// Change the position of the cursor, with the given position of
/// the mouse (relative to the layout). Is blocking is true, the /// the mouse (relative to the layout). Is blocking is true, the
......
...@@ -159,7 +159,8 @@ void CtrlSliderCursor::draw( OSGraphics &rImage, int xDest, int yDest ) ...@@ -159,7 +159,8 @@ void CtrlSliderCursor::draw( OSGraphics &rImage, int xDest, int yDest )
} }
void CtrlSliderCursor::onUpdate( Subject<VarPercent> &rVariable ) void CtrlSliderCursor::onUpdate( Subject<VarPercent,void*> &rVariable,
void *arg )
{ {
// The position has changed // The position has changed
refreshLayout(); refreshLayout();
...@@ -425,7 +426,7 @@ void CtrlSliderBg::associateCursor( CtrlSliderCursor &rCursor ) ...@@ -425,7 +426,7 @@ void CtrlSliderBg::associateCursor( CtrlSliderCursor &rCursor )
} }
void CtrlSliderBg::onUpdate( Subject<VarPercent> &rVariable ) void CtrlSliderBg::onUpdate( Subject<VarPercent, void*> &rVariable, void*arg )
{ {
m_position = (int)( m_rVariable.get() * (m_nbHoriz * m_nbVert - 1) ); m_position = (int)( m_rVariable.get() * (m_nbHoriz * m_nbVert - 1) );
notifyLayout( m_bgWidth, m_bgHeight ); notifyLayout( m_bgWidth, m_bgHeight );
......
...@@ -37,7 +37,7 @@ class VarPercent; ...@@ -37,7 +37,7 @@ class VarPercent;
/// Cursor of a slider /// Cursor of a slider
class CtrlSliderCursor: public CtrlGeneric, public Observer<VarPercent> class CtrlSliderCursor: public CtrlGeneric, public Observer<VarPercent, void*>
{ {
public: public:
/// Create a cursor with 3 images (which are NOT copied, be careful) /// Create a cursor with 3 images (which are NOT copied, be careful)
...@@ -98,7 +98,7 @@ class CtrlSliderCursor: public CtrlGeneric, public Observer<VarPercent> ...@@ -98,7 +98,7 @@ class CtrlSliderCursor: public CtrlGeneric, public Observer<VarPercent>
const Bezier &m_rCurve; const Bezier &m_rCurve;
/// Method called when the position variable is modified /// Method called when the position variable is modified
virtual void onUpdate( Subject<VarPercent> &rVariable ); virtual void onUpdate( Subject<VarPercent,void*> &rVariable, void * );
/// Method to compute the resize factors /// Method to compute the resize factors
void getResizeFactors( float &rFactorX, float &rFactorY ) const; void getResizeFactors( float &rFactorX, float &rFactorY ) const;
...@@ -109,7 +109,7 @@ class CtrlSliderCursor: public CtrlGeneric, public Observer<VarPercent> ...@@ -109,7 +109,7 @@ class CtrlSliderCursor: public CtrlGeneric, public Observer<VarPercent>
/// Slider background /// Slider background
class CtrlSliderBg: public CtrlGeneric, public Observer<VarPercent> class CtrlSliderBg: public CtrlGeneric, public Observer<VarPercent, void*>
{ {
public: public:
CtrlSliderBg( intf_thread_t *pIntf, CtrlSliderBg( intf_thread_t *pIntf,
...@@ -157,7 +157,7 @@ class CtrlSliderBg: public CtrlGeneric, public Observer<VarPercent> ...@@ -157,7 +157,7 @@ class CtrlSliderBg: public CtrlGeneric, public Observer<VarPercent>
int m_position; int m_position;
/// Method called when the observed variable is modified /// Method called when the observed variable is modified
virtual void onUpdate( Subject<VarPercent> &rVariable ); virtual void onUpdate( Subject<VarPercent,void*> &rVariable, void* );
/// Method to compute the resize factors /// Method to compute the resize factors
void getResizeFactors( float &rFactorX, float &rFactorY ) const; void getResizeFactors( float &rFactorX, float &rFactorY ) const;
......
...@@ -214,7 +214,7 @@ void CtrlText::setText( const UString &rText, uint32_t color ) ...@@ -214,7 +214,7 @@ void CtrlText::setText( const UString &rText, uint32_t color )
} }
void CtrlText::onUpdate( Subject<VarText> &rVariable ) void CtrlText::onUpdate( Subject<VarText, void*> &rVariable, void* arg )
{ {
displayText( m_rVariable.get() ); displayText( m_rVariable.get() );
} }
......
...@@ -38,7 +38,7 @@ class VarText; ...@@ -38,7 +38,7 @@ class VarText;
/// Class for control text /// Class for control text
class CtrlText: public CtrlGeneric, public Observer<VarText> class CtrlText: public CtrlGeneric, public Observer<VarText, void*>
{ {
public: public:
enum Align_t enum Align_t
...@@ -122,7 +122,7 @@ class CtrlText: public CtrlGeneric, public Observer<VarText> ...@@ -122,7 +122,7 @@ class CtrlText: public CtrlGeneric, public Observer<VarText>
DEFINE_CALLBACK( CtrlText, UpdateText ); DEFINE_CALLBACK( CtrlText, UpdateText );
/// Method called when the observed variable is modified /// Method called when the observed variable is modified
virtual void onUpdate( Subject<VarText> &rVariable ); virtual void onUpdate( Subject<VarText,void*> &rVariable, void* );
/// Display the text on the control /// Display the text on the control
void displayText( const UString &rText ); void displayText( const UString &rText );
......
...@@ -130,13 +130,14 @@ int CtrlTree::maxItems() ...@@ -130,13 +130,14 @@ int CtrlTree::maxItems()
} }
void CtrlTree::onUpdate( Subject<VarTree> &rTree ) void CtrlTree::onUpdate( Subject<VarTree, int> &rTree, int arg )
{ {
fprintf( stderr, "Doing update type %i\n", arg );
autoScroll(); autoScroll();
m_pLastSelected = NULL; m_pLastSelected = NULL;
} }
void CtrlTree::onUpdate( Subject<VarPercent> &rPercent ) void CtrlTree::onUpdate( Subject<VarPercent, void*> &rPercent, void* arg)
{ {
// Determine what is the first item to display // Determine what is the first item to display
VarTree::Iterator it = m_rTree.begin(); VarTree::Iterator it = m_rTree.begin();
......
...@@ -33,8 +33,8 @@ class GenericFont; ...@@ -33,8 +33,8 @@ class GenericFont;
class GenericBitmap; class GenericBitmap;
/// Class for control tree /// Class for control tree
class CtrlTree: public CtrlGeneric, public Observer<VarTree>, class CtrlTree: public CtrlGeneric, public Observer<VarTree, int>,
public Observer<VarPercent> public Observer<VarPercent, void*>
{ {
public: public:
CtrlTree( intf_thread_t *pIntf, CtrlTree( intf_thread_t *pIntf,
...@@ -102,10 +102,10 @@ class CtrlTree: public CtrlGeneric, public Observer<VarTree>, ...@@ -102,10 +102,10 @@ class CtrlTree: public CtrlGeneric, public Observer<VarTree>,
VarTree::Iterator m_lastPos; VarTree::Iterator m_lastPos;
/// Method called when the tree variable is modified /// Method called when the tree variable is modified
virtual void onUpdate( Subject<VarTree> &rTree ); virtual void onUpdate( Subject<VarTree, int> &rTree , int);
// Method called when the position variable of the tree is modified // Method called when the position variable of the tree is modified
virtual void onUpdate( Subject<VarPercent> &rPercent ); virtual void onUpdate( Subject<VarPercent, void *> &rPercent , void *);
/// Called when the position is set /// Called when the position is set
virtual void onPositionChange(); virtual void onPositionChange();
......
...@@ -109,7 +109,7 @@ void CtrlVideo::draw( OSGraphics &rImage, int xDest, int yDest ) ...@@ -109,7 +109,7 @@ void CtrlVideo::draw( OSGraphics &rImage, int xDest, int yDest )
} }
void CtrlVideo::onUpdate( Subject<VarBox> &rVoutSize ) void CtrlVideo::onUpdate( Subject<VarBox, void *> &rVoutSize, void *arg )
{ {
int newWidth = ((VarBox&)rVoutSize).getWidth() + m_xShift; int newWidth = ((VarBox&)rVoutSize).getWidth() + m_xShift;
int newHeight = ((VarBox&)rVoutSize).getHeight() + m_yShift; int newHeight = ((VarBox&)rVoutSize).getHeight() + m_yShift;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
class VoutWindow; class VoutWindow;
/// Control video /// Control video
class CtrlVideo: public CtrlGeneric, public Observer<VarBox> class CtrlVideo: public CtrlGeneric, public Observer<VarBox, void*>
{ {
public: public:
CtrlVideo( intf_thread_t *pIntf, GenericLayout &rLayout, CtrlVideo( intf_thread_t *pIntf, GenericLayout &rLayout,
...@@ -56,7 +56,7 @@ class CtrlVideo: public CtrlGeneric, public Observer<VarBox> ...@@ -56,7 +56,7 @@ class CtrlVideo: public CtrlGeneric, public Observer<VarBox>
virtual string getType() const { return "video"; } virtual string getType() const { return "video"; }
/// Method called when the vout size is updated /// Method called when the vout size is updated
virtual void onUpdate( Subject<VarBox> &rVoutSize ); virtual void onUpdate( Subject<VarBox,void*> &rVoutSize, void* );
private: private:
/// Vout window /// Vout window
......
...@@ -34,7 +34,8 @@ class OSTimer; ...@@ -34,7 +34,8 @@ class OSTimer;
/// Animated bitmap /// Animated bitmap
class AnimBitmap: public SkinObject, public Box, public Subject<AnimBitmap> class AnimBitmap: public SkinObject, public Box,
public Subject<AnimBitmap, void*>
{ {
public: public:
AnimBitmap( intf_thread_t *pIntf, const GenericBitmap &rBitmap ); AnimBitmap( intf_thread_t *pIntf, const GenericBitmap &rBitmap );
......
...@@ -122,7 +122,7 @@ void GenericWindow::toggleOnTop( bool onTop ) const ...@@ -122,7 +122,7 @@ void GenericWindow::toggleOnTop( bool onTop ) const
} }
void GenericWindow::onUpdate( Subject<VarBool> &rVariable ) void GenericWindow::onUpdate( Subject<VarBool, void*> &rVariable, void*arg )
{ {
if( m_varVisible.get() ) if( m_varVisible.get() )
{ {
......
...@@ -41,7 +41,7 @@ class WindowManager; ...@@ -41,7 +41,7 @@ class WindowManager;
/// Generic window class /// Generic window class
class GenericWindow: public SkinObject, public Observer<VarBool> class GenericWindow: public SkinObject, public Observer<VarBool, void*>
{ {
private: private:
friend class WindowManager; friend class WindowManager;
...@@ -120,7 +120,7 @@ class GenericWindow: public SkinObject, public Observer<VarBool> ...@@ -120,7 +120,7 @@ class GenericWindow: public SkinObject, public Observer<VarBool>
mutable VarBoolImpl m_varVisible; mutable VarBoolImpl m_varVisible;
/// Method called when the observed variable is modified /// Method called when the observed variable is modified
virtual void onUpdate( Subject<VarBool> &rVariable ); virtual void onUpdate( Subject<VarBool, void*> &rVariable , void*);
}; };
......
...@@ -74,7 +74,7 @@ void Tooltip::hide() ...@@ -74,7 +74,7 @@ void Tooltip::hide()
} }
void Tooltip::onUpdate( Subject<VarText> &rVariable ) void Tooltip::onUpdate( Subject<VarText, void*> &rVariable , void *arg)
{ {
// Redisplay the tooltip // Redisplay the tooltip
displayText( ((VarText&)rVariable).get() ); displayText( ((VarText&)rVariable).get() );
......
...@@ -35,7 +35,7 @@ class OSGraphics; ...@@ -35,7 +35,7 @@ class OSGraphics;
class UString; class UString;
class Tooltip: public SkinObject, public Observer<VarText> class Tooltip: public SkinObject, public Observer<VarText, void*>
{ {
public: public:
/// Create a tooltip with the given font and delay (in milliseconds) /// Create a tooltip with the given font and delay (in milliseconds)
...@@ -65,7 +65,7 @@ class Tooltip: public SkinObject, public Observer<VarText> ...@@ -65,7 +65,7 @@ class Tooltip: public SkinObject, public Observer<VarText>
int m_xPos, m_yPos; int m_xPos, m_yPos;
/// Method called when the observed variable is modified /// Method called when the observed variable is modified
virtual void onUpdate( Subject<VarText> &rVariable ); virtual void onUpdate( Subject<VarText,void*> &rVariable, void * );
/// Display text of the tooltip /// Display text of the tooltip
void displayText( const UString &rText ); void displayText( const UString &rText );
......
...@@ -28,11 +28,11 @@ ...@@ -28,11 +28,11 @@
#include <set> #include <set>
// Forward declaration // Forward declaration
template <class S> class Observer; template <class S, class ARG> class Observer;
/// Template for subjects in the Observer design pattern /// Template for subjects in the Observer design pattern
template <class S> class Subject template <class S, class ARG> class Subject
{ {
public: public:
virtual ~Subject() {} virtual ~Subject() {}
...@@ -45,23 +45,23 @@ template <class S> class Subject ...@@ -45,23 +45,23 @@ template <class S> class Subject
/// Add an observer to this subject /// Add an observer to this subject
/// Note: adding twice the same observer is not harmful /// Note: adding twice the same observer is not harmful
virtual void addObserver( Observer<S>* pObserver ) virtual void addObserver( Observer<S, ARG>* pObserver )
{ {
m_observers.insert( pObserver ); m_observers.insert( pObserver );
} }
/// Remove an observer from this subject /// Remove an observer from this subject
/// Note: removing twice the same observer is not harmful /// Note: removing twice the same observer is not harmful
virtual void delObserver( Observer<S>* pObserver ) virtual void delObserver( Observer<S, ARG>* pObserver )
{ {
m_observers.erase( pObserver ); m_observers.erase( pObserver );
} }
/// Notify the observers when the status has changed /// Notify the observers when the status has changed
virtual void notify() virtual void notify( ARG arg )
{ {
// This stupid gcc 3.2 needs "typename" // This stupid gcc 3.2 needs "typename"
typename set<Observer<S>*>::const_iterator iter; typename set<Observer<S, ARG>*>::const_iterator iter;
for( iter = m_observers.begin(); iter != m_observers.end(); for( iter = m_observers.begin(); iter != m_observers.end();
iter++ ) iter++ )
{ {
...@@ -70,27 +70,30 @@ template <class S> class Subject ...@@ -70,27 +70,30 @@ template <class S> class Subject
fprintf( stderr, "iter NULL !\n" ); fprintf( stderr, "iter NULL !\n" );
return; return;
} }
(*iter)->onUpdate( *this ); (*iter)->onUpdate( *this , arg );
} }
} }
/// Notify without any argument
virtual void notify() { notify( NULL ); }
protected: protected:
Subject() {} Subject() {}
private: private:
/// Set of observers for this subject /// Set of observers for this subject
set<Observer<S>*> m_observers; set<Observer<S, ARG>*> m_observers;
}; };
/// Template for observers in the Observer design pattern /// Template for observers in the Observer design pattern
template <class S> class Observer template <class S, class ARG> class Observer
{ {
public: public:
virtual ~Observer() {} virtual ~Observer() {}
/// Method called when the subject is modified /// Method called when the subject is modified
virtual void onUpdate( Subject<S> &rSubject ) = 0; virtual void onUpdate( Subject<S,ARG> &rSubject , ARG arg) = 0;
protected: protected:
Observer() {} Observer() {}
......
...@@ -109,7 +109,7 @@ class Position ...@@ -109,7 +109,7 @@ class Position
/// Variable implementing the Box interface /// Variable implementing the Box interface
class VarBox: public Variable, public Box, public Subject<VarBox> class VarBox: public Variable, public Box, public Subject<VarBox, void*>
{ {
public: public:
VarBox( intf_thread_t *pIntf, int width = 0, int height = 0 ); VarBox( intf_thread_t *pIntf, int width = 0, int height = 0 );
......
...@@ -60,7 +60,7 @@ VarBoolAndBool::~VarBoolAndBool() ...@@ -60,7 +60,7 @@ VarBoolAndBool::~VarBoolAndBool()
} }
void VarBoolAndBool::onUpdate( Subject<VarBool> &rVariable ) void VarBoolAndBool::onUpdate( Subject<VarBool,void *> &rVariable, void *arg )
{ {
notify(); notify();
} }
...@@ -82,7 +82,7 @@ VarBoolOrBool::~VarBoolOrBool() ...@@ -82,7 +82,7 @@ VarBoolOrBool::~VarBoolOrBool()
} }
void VarBoolOrBool::onUpdate( Subject<VarBool> &rVariable ) void VarBoolOrBool::onUpdate( Subject<VarBool,void*> &rVariable , void*arg)
{ {
notify(); notify();
} }
...@@ -101,7 +101,7 @@ VarNotBool::~VarNotBool() ...@@ -101,7 +101,7 @@ VarNotBool::~VarNotBool()
} }
void VarNotBool::onUpdate( Subject<VarBool> &rVariable ) void VarNotBool::onUpdate( Subject<VarBool, void*> &rVariable, void*arg )
{ {
notify(); notify();
} }
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
/// Interface for read-only boolean variable /// Interface for read-only boolean variable
class VarBool: public Variable, public Subject<VarBool> class VarBool: public Variable, public Subject<VarBool, void *>
{ {
public: public:
/// Get the variable type /// Get the variable type
...@@ -89,7 +89,7 @@ class VarBoolImpl: public VarBool ...@@ -89,7 +89,7 @@ class VarBoolImpl: public VarBool
/// Conjunction of two boolean variables (AND) /// Conjunction of two boolean variables (AND)
class VarBoolAndBool: public VarBool, public Observer<VarBool> class VarBoolAndBool: public VarBool, public Observer<VarBool, void*>
{ {
public: public:
VarBoolAndBool( intf_thread_t *pIntf, VarBool &rVar1, VarBool &rVar2 ); VarBoolAndBool( intf_thread_t *pIntf, VarBool &rVar1, VarBool &rVar2 );
...@@ -99,7 +99,7 @@ class VarBoolAndBool: public VarBool, public Observer<VarBool> ...@@ -99,7 +99,7 @@ class VarBoolAndBool: public VarBool, public Observer<VarBool>
virtual bool get() const { return m_rVar1.get() && m_rVar2.get(); } virtual bool get() const { return m_rVar1.get() && m_rVar2.get(); }
// Called when one of the observed variables is changed // Called when one of the observed variables is changed
void onUpdate( Subject<VarBool> &rVariable ); void onUpdate( Subject<VarBool, void*> &rVariable, void* );
private: private:
/// Boolean variables /// Boolean variables
...@@ -108,7 +108,7 @@ class VarBoolAndBool: public VarBool, public Observer<VarBool> ...@@ -108,7 +108,7 @@ class VarBoolAndBool: public VarBool, public Observer<VarBool>
/// Disjunction of two boolean variables (OR) /// Disjunction of two boolean variables (OR)
class VarBoolOrBool: public VarBool, public Observer<VarBool> class VarBoolOrBool: public VarBool, public Observer<VarBool, void*>
{ {
public: public:
VarBoolOrBool( intf_thread_t *pIntf, VarBool &rVar1, VarBool &rVar2 ); VarBoolOrBool( intf_thread_t *pIntf, VarBool &rVar1, VarBool &rVar2 );
...@@ -118,7 +118,7 @@ class VarBoolOrBool: public VarBool, public Observer<VarBool> ...@@ -118,7 +118,7 @@ class VarBoolOrBool: public VarBool, public Observer<VarBool>
virtual bool get() const { return m_rVar1.get() || m_rVar2.get(); } virtual bool get() const { return m_rVar1.get() || m_rVar2.get(); }
// Called when one of the observed variables is changed // Called when one of the observed variables is changed
void onUpdate( Subject<VarBool> &rVariable ); void onUpdate( Subject<VarBool, void*> &rVariable, void* );
private: private:
/// Boolean variables /// Boolean variables
...@@ -127,7 +127,7 @@ class VarBoolOrBool: public VarBool, public Observer<VarBool> ...@@ -127,7 +127,7 @@ class VarBoolOrBool: public VarBool, public Observer<VarBool>
/// Negation of a boolean variable (NOT) /// Negation of a boolean variable (NOT)
class VarNotBool: public VarBool, public Observer<VarBool> class VarNotBool: public VarBool, public Observer<VarBool, void*>
{ {
public: public:
VarNotBool( intf_thread_t *pIntf, VarBool &rVar ); VarNotBool( intf_thread_t *pIntf, VarBool &rVar );
...@@ -137,7 +137,7 @@ class VarNotBool: public VarBool, public Observer<VarBool> ...@@ -137,7 +137,7 @@ class VarNotBool: public VarBool, public Observer<VarBool>
virtual bool get() const { return !m_rVar.get(); } virtual bool get() const { return !m_rVar.get(); }
// Called when the observed variable is changed // Called when the observed variable is changed
void onUpdate( Subject<VarBool> &rVariable ); void onUpdate( Subject<VarBool, void*> &rVariable, void* );
private: private:
/// Boolean variable /// Boolean variable
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
/// List variable /// List variable
class VarList: public Variable, public Subject<VarList> class VarList: public Variable, public Subject<VarList, void* >
{ {
public: public:
VarList( intf_thread_t *pIntf ); VarList( intf_thread_t *pIntf );
......
...@@ -43,7 +43,7 @@ void VarPercent::set( float percentage ) ...@@ -43,7 +43,7 @@ void VarPercent::set( float percentage )
if( m_value != percentage ) if( m_value != percentage )
{ {
m_value = percentage; m_value = percentage;
notify(); notify( NULL );
} }
} }
...@@ -32,7 +32,7 @@ class VarPercent; ...@@ -32,7 +32,7 @@ class VarPercent;
/// Percentage variable /// Percentage variable
class VarPercent: public Variable, public Subject<VarPercent> class VarPercent: public Variable, public Subject<VarPercent, void*>
{ {
public: public:
VarPercent( intf_thread_t *pIntf ): Variable( pIntf ), m_value( 0 ) {} VarPercent( intf_thread_t *pIntf ): Variable( pIntf ), m_value( 0 ) {}
......
...@@ -185,7 +185,7 @@ void VarText::set( const UString &rText ) ...@@ -185,7 +185,7 @@ void VarText::set( const UString &rText )
} }
void VarText::onUpdate( Subject<VarPercent> &rVariable ) void VarText::onUpdate( Subject<VarPercent, void*> &rVariable, void *arg )
{ {
UString newText = get(); UString newText = get();
// If the text has changed, notify the observers // If the text has changed, notify the observers
...@@ -197,7 +197,7 @@ void VarText::onUpdate( Subject<VarPercent> &rVariable ) ...@@ -197,7 +197,7 @@ void VarText::onUpdate( Subject<VarPercent> &rVariable )
} }
void VarText::onUpdate( Subject<VarText> &rVariable ) void VarText::onUpdate( Subject<VarText,void*> &rVariable, void *arg )
{ {
UString newText = get(); UString newText = get();
// If the text has changed, notify the observers // If the text has changed, notify the observers
......
...@@ -32,8 +32,9 @@ ...@@ -32,8 +32,9 @@
/// String variable /// String variable
class VarText: public Variable, public Subject<VarText>, class VarText: public Variable, public Subject<VarText, void*>,
public Observer<VarPercent>, public Observer< VarText > public Observer<VarPercent, void*>,
public Observer< VarText,void*>
{ {
public: public:
// Set substVars to true to replace "$X" variables in the text // Set substVars to true to replace "$X" variables in the text
...@@ -48,8 +49,8 @@ class VarText: public Variable, public Subject<VarText>, ...@@ -48,8 +49,8 @@ class VarText: public Variable, public Subject<VarText>,
virtual const UString get() const; virtual const UString get() const;
/// Methods called when an observed variable is modified /// Methods called when an observed variable is modified
virtual void onUpdate( Subject<VarPercent> &rVariable ); virtual void onUpdate( Subject<VarPercent, void*> &rVariable, void* );
virtual void onUpdate( Subject<VarText> &rVariable ); virtual void onUpdate( Subject<VarText, void*> &rVariable, void* );
private: private:
/// Variable type /// Variable type
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* var_tree.hpp * var_tree.hpp
***************************************************************************** *****************************************************************************
* Copyright (C) 2005 VideoLAN * Copyright (C) 2005 VideoLAN
* $Id: var_bool.hpp 9934 2005-02-15 13:55:08Z courmisch $ * $Id$
* *
* Authors: Antoine Cellerier <dionoea@videolan.org> * Authors: Antoine Cellerier <dionoea@videolan.org>
* *
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
#include "var_percent.hpp" #include "var_percent.hpp"
/// Tree variable /// Tree variable
class VarTree: public Variable, public Subject<VarTree> class VarTree: public Variable, public Subject<VarTree, int>
{ {
public: public:
VarTree( intf_thread_t *pIntf ); VarTree( intf_thread_t *pIntf );
......
...@@ -77,7 +77,7 @@ VariablePtr EqualizerBands::getBand( int band ) ...@@ -77,7 +77,7 @@ VariablePtr EqualizerBands::getBand( int band )
} }
void EqualizerBands::onUpdate( Subject<VarPercent> &rBand ) void EqualizerBands::onUpdate( Subject<VarPercent,void*> &rBand, void *arg )
{ {
// Make sure we are not called from set() // Make sure we are not called from set()
if (!m_isUpdating) if (!m_isUpdating)
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
/// Variable for graphical equalizer /// Variable for graphical equalizer
class EqualizerBands: public SkinObject, public Observer<VarPercent> class EqualizerBands: public SkinObject, public Observer<VarPercent, void*>
{ {
public: public:
/// Number of bands /// Number of bands
...@@ -52,7 +52,7 @@ class EqualizerBands: public SkinObject, public Observer<VarPercent> ...@@ -52,7 +52,7 @@ class EqualizerBands: public SkinObject, public Observer<VarPercent>
bool m_isUpdating; bool m_isUpdating;
/// Callback for band updates /// Callback for band updates
virtual void onUpdate( Subject<VarPercent> &rBand ); virtual void onUpdate( Subject<VarPercent, void*> &rBand , void *);
}; };
......
...@@ -78,7 +78,7 @@ void Playtree::delSelected() ...@@ -78,7 +78,7 @@ void Playtree::delSelected()
} }
} }
buildTree(); buildTree();
notify(); notify( 1 );
} }
void Playtree::action( VarTree *pItem ) void Playtree::action( VarTree *pItem )
...@@ -106,7 +106,7 @@ void Playtree::action( VarTree *pItem ) ...@@ -106,7 +106,7 @@ void Playtree::action( VarTree *pItem )
void Playtree::onChange() void Playtree::onChange()
{ {
buildTree(); buildTree();
notify(); notify( 1 );
} }
void Playtree::onUpdate( int id ) void Playtree::onUpdate( int id )
...@@ -125,7 +125,7 @@ void Playtree::onUpdate( int id ) ...@@ -125,7 +125,7 @@ void Playtree::onUpdate( int id )
msg_Warn(getIntf(), "Cannot find node with id %d", id ); msg_Warn(getIntf(), "Cannot find node with id %d", id );
} }
// TODO update only the right node // TODO update only the right node
notify(); notify( 0 );
} }
void Playtree::buildNode( playlist_item_t *pNode, VarTree &rTree ) void Playtree::buildNode( playlist_item_t *pNode, VarTree &rTree )
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment