Libraries/UPnP/src/include/Network/UPnP/Object.h
Go to the documentation of this file.
1 /****
2  * Object.h
3  *
4  * Copyright 2019 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 "BaseObject.h"
23 #include "ObjectClass.h"
24 #include <WString.h>
25 #include <Delegate.h>
31 #include <Network/SSDP/Urn.h>
32 
33 namespace UPnP
34 {
35 class Object;
36 
37 class Object : public BaseObject
38 {
39 public:
41 
42  virtual const ObjectClass& getClass() const = 0;
43 
44  Object* getNext() const
45  {
46  return reinterpret_cast<Object*>(LinkedItem::next());
47  }
48 
49  bool typeIs(const Urn& objectType) const
50  {
51  return objectType == this->objectType();
52  }
53 
54  bool typeIs(const String& objectType) const
55  {
56  return this->objectType() == objectType;
57  }
58 
59  bool typeIs(const ObjectClass& objectClass) const
60  {
61  return typeIs(objectClass.objectType());
62  }
63 
64  virtual Urn objectType() const
65  {
66  return getClass().objectType();
67  }
68 
69  virtual Version version() const
70  {
71  return getClass().version();
72  }
73 
77  virtual void search(const SearchFilter& filter) = 0;
78 
86  virtual bool onHttpRequest(HttpServerConnection& connection)
87  {
88  return false;
89  }
90 
99  {
100  return nullptr;
101  }
102 };
103 
104 } // namespace UPnP
Definition: HttpServerConnection.h:34
Base class for read-only stream.
Definition: DataSourceStream.h:46
The String class.
Definition: WString.h:137
Objects which hook into the SSDP message stack.
Definition: BaseObject.h:56
Item * next() const override
Definition: LinkedItem.h:34
Definition: Libraries/UPnP/src/include/Network/UPnP/Object.h:38
virtual bool onHttpRequest(HttpServerConnection &connection)
Called by framework to handle an incoming HTTP request.
Definition: Libraries/UPnP/src/include/Network/UPnP/Object.h:86
virtual const ObjectClass & getClass() const =0
bool typeIs(const String &objectType) const
Definition: Libraries/UPnP/src/include/Network/UPnP/Object.h:54
virtual IDataSourceStream * createDescription()
Called by framework to construct a device description response stream.
Definition: Libraries/UPnP/src/include/Network/UPnP/Object.h:98
virtual void search(const SearchFilter &filter)=0
Called during SSDP search operation.
virtual Version version() const
Definition: Libraries/UPnP/src/include/Network/UPnP/Object.h:69
ObjectClass::Version Version
Definition: Libraries/UPnP/src/include/Network/UPnP/Object.h:40
virtual Urn objectType() const
Definition: Libraries/UPnP/src/include/Network/UPnP/Object.h:64
bool typeIs(const ObjectClass &objectClass) const
Definition: Libraries/UPnP/src/include/Network/UPnP/Object.h:59
Object * getNext() const
Definition: Libraries/UPnP/src/include/Network/UPnP/Object.h:44
bool typeIs(const Urn &objectType) const
Definition: Libraries/UPnP/src/include/Network/UPnP/Object.h:49
Structure for UPnP URNs.
Definition: Urn.h:41
Definition: ActionRequest.h:25
Describes device or service class.
Definition: ObjectClass.h:36
Version version() const
Definition: ObjectClass.h:106
Urn objectType() const
uint8_t Version
Interface version number.
Definition: ObjectClass.h:43
Definition: BaseObject.h:39