SoDaRadio-12.2.0-cut_dependencies:6c82803
Loading...
Searching...
No Matches
SimpleAccessory.hxx
Go to the documentation of this file.
1/*
2 Copyright (c) 2019, 2025 Matthew H. Reilly (kb1vc)
3 All rights reserved.
4
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are
7 met:
8
9 Redistributions of source code must retain the above copyright
10 notice, this list of conditions and the following disclaimer.
11 Redistributions in binary form must reproduce the above copyright
12 notice, this list of conditions and the following disclaimer in
13 the documentation and/or other materials provided with the
14 distribution.
15
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27*/
28
29#pragma once
30
31#include "Command.hxx"
32#include "SoDaBase.hxx"
33#include "SoDaThread.hxx"
34
45
46// namespace doesn't matter here... let's do without.
47class SimpleAccessory;
48typedef std::shared_ptr<SimpleAccessory> SimpleAccessoryPtr;
49
50extern "C" {
51 bool initPlugin();
52}
53
55private:
56 // gotta do this to make the base object directory work... sigh.
57 SimpleAccessory(const std::string & name);
58
59public:
60 static SimpleAccessoryPtr make(const std::string & name) {
61 auto ret = std::shared_ptr<SimpleAccessory>(new SimpleAccessory(name));
62 ret->self = ret;
63 ret->registerThread(ret);
64 return ret;
65 }
66
72 void subscribeToMailBoxes(const std::vector<SoDa::MailBoxBasePtr> & mailboxes);
73
74 void run();
75
83
90
97
98 void shutDown() {
100 }
101
103
104 SoDa::CmdMBox::Subscription cmd_subs;
106
108};
109
std::shared_ptr< SimpleAccessory > SimpleAccessoryPtr
bool initPlugin()
The Baseclass for all SoDa objects, and useful commonly used classes.
The Baseclass for all SoDa thread objects.
void execSetCommand(SoDa::CommandPtr cmd)
handle SET commands from the command channel
void shutDown()
optional method that performs cleanup – may not delete.
SimpleAccessory(const std::string &name)
SoDa::CmdMBox::Subscription cmd_subs
mailbox subscription ID for command stream
SoDa::CmdMBoxPtr cmd_stream
mailbox producing command stream from user
unsigned int get_count
void run()
Each thread object must define its "run" loop.
void execRepCommand(SoDa::CommandPtr cmd)
handle Report commands from the command channel
unsigned int rep_count
void execGetCommand(SoDa::CommandPtr cmd)
execute GET commands from the command channel
unsigned int set_count
void subscribeToMailBoxes(const std::vector< SoDa::MailBoxBasePtr > &mailboxes)
connect to useful mailboxes.
static SimpleAccessoryPtr make(const std::string &name)
The Thread baseclass for all SoDa thread objects.
std::shared_ptr< Command > CommandPtr
Definition Command.hxx:41
std::shared_ptr< CmdMBox > CmdMBoxPtr
Definition SoDaBase.hxx:79