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
Base class for read-only stream.
Definition: DataSourceStream.h:45
ObjectClass::Version Version
Definition: Libraries/UPnP/src/include/Network/UPnP/Object.h:57
Definition: BaseObject.h:56
The String class.
Definition: WString.h:136
virtual const ObjectClass & getClass() const =0
Version version() const
Definition: ObjectClass.h:123
virtual Urn objectType() const
Definition: Libraries/UPnP/src/include/Network/UPnP/Object.h:81
virtual bool onHttpRequest(HttpServerConnection &connection)
Called by framework to handle an incoming HTTP request.
Definition: Libraries/UPnP/src/include/Network/UPnP/Object.h:103
virtual IDataSourceStream * createDescription()
Called by framework to construct a device description response stream.
Definition: Libraries/UPnP/src/include/Network/UPnP/Object.h:115
uint8_t Version
Interface version number.
Definition: ObjectClass.h:60
LinkedItem * next() const override
Definition: LinkedItem.h:51
Structure for UPnP URNs.
Definition: Urn.h:40
virtual Version version() const
Definition: Libraries/UPnP/src/include/Network/UPnP/Object.h:86
Describes device or service class.
Definition: ObjectClass.h:53
Definition: ActionRequest.h:24
virtual void search(const SearchFilter &filter)=0
Called during SSDP search operation.
Object * getNext() const
Definition: Libraries/UPnP/src/include/Network/UPnP/Object.h:61
Urn objectType() const
bool typeIs(const Urn &objectType) const
Definition: Libraries/UPnP/src/include/Network/UPnP/Object.h:66
Definition: HttpServerConnection.h:33