Follow this link to skip to the main content

claraty::Power_Switch Class Reference

#include <power_switch.h>

List of all members.

Public Member Functions

 Power_Switch ()
virtual ~Power_Switch ()
bool set (bool state)
bool get () const
bool is_switchable () const
virtual std::string get_name () const
virtual bool io (FDM_Map map)

Protected Member Functions

bool _set (bool state)

Private Attributes

bool _is_switchable
bool _switch_on


Detailed Description

Power_Switch_Func is an abstract base class for a power switch used by Device. A Power_Switch_Func supports the following methods:
  • Set the value, true to turn on, false to turn off
  • Get the current state, true if currently on, false if currently off
  • Get name, which is used by the device factory to instantiate from serialized attributes
  • Ask the power switch if it can be turned off. This is needed because manual switches cannot be turned on and off but are read only switches

Definition at line 45 of file power_switch.h.


Constructor & Destructor Documentation

claraty::Power_Switch::Power_Switch (  )  [inline]

Definition at line 47 of file power_switch.h.

00047 : _is_switchable(true), _switch_on(true) {};

virtual claraty::Power_Switch::~Power_Switch (  )  [inline, virtual]

Definition at line 48 of file power_switch.h.

00048 { }


Member Function Documentation

bool claraty::Power_Switch::set ( bool  state  )  [inline]

Definition at line 50 of file power_switch.h.

References _set(), and _switch_on.

Referenced by claraty::Device::off(), and claraty::Device::on().

00050 { _switch_on = state; return _set(state); }

Here is the call graph for this function:

bool claraty::Power_Switch::get (  )  const [inline]

Definition at line 51 of file power_switch.h.

References _switch_on.

Referenced by claraty::Device::is_on().

00051 { return _switch_on; }

bool claraty::Power_Switch::is_switchable (  )  const [inline]

Definition at line 52 of file power_switch.h.

References _is_switchable.

00052 { return _is_switchable; }

virtual std::string claraty::Power_Switch::get_name (  )  const [inline, virtual]

Definition at line 54 of file power_switch.h.

00054 { return("default_power_switch"); }

bool claraty::Power_Switch::io ( FDM_Map  map  )  [inline, virtual]

Maps the data members of the power switch function object for sending over a serial medium

Parameters:
[out] map A serial object that contains the device data members.
Returns:
true if serialization succeeds, false otherwise.

Definition at line 79 of file power_switch.h.

References _is_switchable, _switch_on, and claraty::FDM_Map::field().

00080 {
00081   bool ok = true;
00082   ok &= map.field("has switch", _is_switchable);
00083   ok &= map.field("switch on",  _switch_on);
00084   return ok;
00085 }

Here is the call graph for this function:

bool claraty::Power_Switch::_set ( bool  state  )  [inline, protected]

Definition at line 60 of file power_switch.h.

Referenced by set().

00060 {return false;}


Member Data Documentation

Definition at line 65 of file power_switch.h.

Referenced by io(), and is_switchable().

Definition at line 66 of file power_switch.h.

Referenced by get(), io(), and set().


The documentation for this class was generated from the following file: