Files
BT411/engine/MUNGA/LAMP.h
T

181 lines
4.4 KiB
C++

#pragma once
#include "gaugrend.h"
#include "style.h"
#include "graph2d.h"
#include "mode.h"
#include "slot.h"
#include "chain.h"
class LampManager;
class GraphicLamp;
typedef int LampID;
typedef int LampState;
//#########################################################################
//################################# Lamp ##################################
//#########################################################################
class Lamp : public Node
{
friend class LampManager;
//----------------------------------------------------------------------
// Public methods
//----------------------------------------------------------------------
public:
enum
{
LampStateUndefined = -1,
LampStateOff = 0,
LampStateOn,
NextLampState
};
virtual ~Lamp();
Logical
TestInstance() const;
virtual void
SetState(LampState new_state);
void
SetAlertState(Logical alert_on = True);
LampState
GetState()
{
Check(this);
return previousState;
}
protected:
//----------------------------------------------------------------------
// Protected methods
//----------------------------------------------------------------------
Lamp(
LampID lamp_id,
ModeMask mode_mask,
LampManager *lamp_manager
);
virtual void
Update(Logical force_notify_of_state_change = False);
virtual void
NotifyOfStateChange();
//
//----------------------------------------------------------------------
// Protected data
//----------------------------------------------------------------------
//
LampID
lampID;
ModeMask
modeMask;
LampState
previousState;
LampManager
*manager;
int
alertActive;
// #135: an alert-state EDGE whose NotifyOfStateChange was skipped by the
// mode gate (page not current, or the one-frame mask race during a page
// transition). The panel value latches the last asserted flash until the
// next assert, so a skipped clear-edge left loop buttons flashing forever
// (field: Oracle night-15, "Loop 6 NEVER stopped"). Delivered by Update()
// at the lamp's next in-mode frame.
Logical
staleAlertNotify;
};
//#########################################################################
//############################## GraphicLamp ##############################
//#########################################################################
class GraphicLamp :
public Lamp
{
//----------------------------------------------------------------------
// Public methods
//----------------------------------------------------------------------
public:
~GraphicLamp();
Logical
TestInstance() const;
//----------------------------------------------------------------------
// Protected methods
//----------------------------------------------------------------------
protected:
GraphicLamp(
LampID lamp_id,
ModeMask mode_mask,
LampManager *lamp_manager,
GaugeRenderer *renderer,
int graphics_port_number
);
//----------------------------------------------------------------------
// Public data
//----------------------------------------------------------------------
GaugeRenderer
*renderer;
GraphicsView
localView;
};
#include "gaugrend.h" // LampManager is a part of GaugeRenderer...
//############################## LampManager ##############################
// The Lamp Manager belongs to the Gauge Renderer: it is responsible for
// handling specialized 'lamp' objects similar to (but not identical to)
// gauge objects.
//#########################################################################
class LampManager SIGNATURED
{
friend class Lamp;
//----------------------------------------------------------------------
// Public methods
//----------------------------------------------------------------------
public:
virtual ~LampManager();
Logical
TestInstance() const;
virtual void
Update(ModeMask current_mode_mask);
Lamp *
FindLamp(LampID lamp_id, ModeMask mode_mask);
void
RemoveAllLamps();
ModeMask
GetPreviousModeMask()
{
Check(this);
Check_Fpu();
return previousModeMask;
}
//----------------------------------------------------------------------
// Protected methods
//----------------------------------------------------------------------
protected:
LampManager();
void
ActivateLamps(ModeMask bits_became_active);
void
DeactivateLamps(ModeMask bits_became_inactive);
void
AddLamp(Lamp *new_lamp);
void
RemoveLamp(LampID lamp_id, ModeMask mode_mask);
ModeMask
previousModeMask;
ChainOf<Lamp*>
lampList,
activeLampList,
inactiveLampList;
};