FlightGear next
AbstractInstrument.hxx
Go to the documentation of this file.
1/*
2 * SPDX-License-Identifier: GPL-2.0+
3 * SPDX-FileCopyrightText: 2019 (C) James Turner <james@flightgear.org>
4 *
5 * AbstractInstrument.hxx
6 *
7 * Copyright (C) 2019 James Turner <james@flightgear.org>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of the
12 * License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22*/
23
24#pragma once
25
26#include <simgear/props/props.hxx>
27#include <simgear/structure/subsystem_mgr.hxx>
28
29class AbstractInstrument : public SGSubsystem
30{
31public:
32
33protected:
34
35 void readConfig(SGPropertyNode* config,
36 std::string defaultName);
37
38 void initServicePowerProperties(SGPropertyNode* node);
39
40 bool isServiceableAndPowered() const;
41
42 // build the path /instrumentation/<name>[number]
43 std::string nodePath() const;
44
45 std::string name() const { return _name; }
46 int number() const { return _index; }
47
48 void unbind() override;
49
50 void setMinimumSupplyVolts(double v);
51
56 void setDefaultPowerSupplyPath(const std::string &p);
57
58 virtual bool isPowerSwitchOn() const;
59private:
60 std::string _name;
61 int _index = 0;
62 std::string _powerSupplyPath;
63
64 SGPropertyNode_ptr _serviceableNode;
65 SGPropertyNode_ptr _powerButtonNode;
66 double _minimumSupplyVolts;
67 SGPropertyNode_ptr _powerSupplyNode;
68};
#define p(x)
void initServicePowerProperties(SGPropertyNode *node)
std::string name() const
virtual bool isPowerSwitchOn() const
void setMinimumSupplyVolts(double v)
void readConfig(SGPropertyNode *config, std::string defaultName)
std::string nodePath() const
void setDefaultPowerSupplyPath(const std::string &p)
specify the default path to use to power the instrument, if it's non- standard.
bool isServiceableAndPowered() const