ServiceControl.h
Go to the documentation of this file.
1 /****
2  * ServiceControl.h
3  *
4  * Copyright 2020 mikee47 <mike@sillyhouse.net>
5  *
6  * This file is part of the Sming UPnP Library
7  *
8  * This library is free software: you can redistribute it and/or modify it under the terms of the
9  * GNU General Public License as published by the Free Software Foundation, version 3 or later.
10  *
11  * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
12  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13  * See the GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along with this library.
16  * If not, see <https://www.gnu.org/licenses/>.
17  *
18  ****/
19 
20 #pragma once
21 
22 #include "Service.h"
23 #include <Data/CString.h>
24 #include <memory>
25 
26 namespace UPnP
27 {
28 class DeviceControl;
29 
30 class ServiceControl : public Service
31 {
32 public:
33  using List = ObjectList<ServiceControl>;
34  using OwnedList = OwnedObjectList<ServiceControl>;
35  using Field = Service::Field;
36 
37  struct Description {
41  };
42 
43  ServiceControl() = delete;
44  ServiceControl(const ServiceControl&) = delete;
45 
46  ServiceControl(DeviceControl& device) : Service(reinterpret_cast<Device&>(device))
47  {
48  }
49 
54  {
55  return reinterpret_cast<DeviceControl&>(Service::root());
56  }
57 
58  const DeviceControl& root() const
59  {
60  return const_cast<ServiceControl*>(this)->root();
61  }
62 
63  String getField(Field desc) const override;
64 
65  ServiceControl* getNext() const
66  {
67  return reinterpret_cast<ServiceControl*>(next());
68  }
69 
70  bool sendRequest(HttpRequest* request) const override;
71 
72  Error handleAction(ActionRequest& req) override
73  {
74  return Error::ActionNotImplemented;
75  }
76 
80  bool configure(const XML::Node* service);
81 
83  {
84  return reinterpret_cast<DeviceControl&>(Service::device());
85  }
86 
90  const Description& description()
91  {
92  return description_;
93  }
94 
95 private:
96  Description description_;
97 };
98 
99 } // namespace UPnP
Service::Field Field
Definition: ServiceControl.h:52
const Description & description()
Get service description.
Definition: ServiceControl.h:107
Error handleAction(ActionRequest &req) override
An action request has been received.
Definition: ServiceControl.h:89
rapidxml::xml_node< char > Node
Definition: RapidXML.h:37
Definition: DeviceControl.h:48
The String class.
Definition: WString.h:136
Definition: ActionRequest.h:43
DeviceControl & root()
Get the root device.
Definition: ServiceControl.h:70
Device & device() const
Definition: UPnP/src/include/Network/UPnP/Service.h:97
CString eventSubURL
Definition: ServiceControl.h:56
Class to manage a NUL-terminated C-style string When storing persistent strings in RAM the regular St...
Definition: CString.h:26
LinkedItem * next() const override
Definition: LinkedItem.h:51
DeviceControl & device() const
Definition: ServiceControl.h:99
Error
Definition: Libraries/UPnP/src/include/Network/UPnP/Error.h:45
ObjectList< ServiceControl > List
Definition: ServiceControl.h:50
bool configure(const XML::Node *service)
Called during initialisation to configure this object.
bool sendRequest(HttpRequest *request) const override
Implemented in ServiceControl.
CString controlURL
Definition: ServiceControl.h:55
ServiceControl * getNext() const
Definition: ServiceControl.h:82
Definition: ActionRequest.h:24
Service(Device &device)
Definition: UPnP/src/include/Network/UPnP/Service.h:60
OwnedObjectList< ServiceControl > OwnedList
Definition: ServiceControl.h:51
Field
Definition: UPnP/src/include/Network/UPnP/Service.h:49
String getField(Field desc) const override
Encapsulates an incoming or outgoing request.
Definition: HttpRequest.h:36
CString serviceId
Definition: ServiceControl.h:57
Definition: ServiceControl.h:47
Device & root()