made some of the dbus API compliant with w3c auto-bg specification
[profile/ivi/automotive-message-broker.git] / lib / abstractsource.h
1 /*
2     Copyright (C) 2012  Intel Corporation
3
4     This library is free software; you can redistribute it and/or
5     modify it under the terms of the GNU Lesser General Public
6     License as published by the Free Software Foundation; either
7     version 2.1 of the License, or (at your option) any later version.
8
9     This library is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12     Lesser General Public License for more details.
13
14     You should have received a copy of the GNU Lesser General Public
15     License along with this library; if not, write to the Free Software
16     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
17 */
18
19
20 #ifndef ABSTRACTSOURCE_H
21 #define ABSTRACTSOURCE_H
22
23 #include <string>
24 #include <list>
25 #include <boost/any.hpp>
26
27 #include "abstractsink.h"
28 #include "vehicleproperty.h"
29 #include "abstractroutingengine.h"
30 #include "abstractpropertytype.h"
31 #include "propertyinfo.hpp"
32
33
34
35 class AbstractSource;
36
37 typedef std::list<AbstractSource*> SourceList;
38
39
40
41 class AbstractSource: public AbstractSink
42 {
43
44 public:
45         /*!
46          * \brief The Operations enum is a bitmask flag used to specify which operations are supported by the source plugin
47          */
48         enum Operations {
49                 Get = 0x01,
50                 Set = 0x02,
51                 GetRanged = 0x04
52         };
53
54         AbstractSource(AbstractRoutingEngine* engine, map<string, string> config);
55         virtual ~AbstractSource();
56         
57         ///pure virtual methods:
58
59         /*!
60          * \brief getPropertyAsync is called when a sink requests the value for given property.
61          * This is only called if the source supports the Get operation (@see Operation)
62          * \param reply the reply variable.  @see AsyncPropertyReply
63          */
64         virtual void getPropertyAsync(AsyncPropertyReply *reply) = 0;
65
66         /*!
67          * \brief getRangePropertyAsync is called when a sink requests a series of values for a given
68          * property within a specified time or sequencial range.  This will only be called if the source
69          * support the Ranged Operation (@see Operations)
70          * \param reply is the reply variable.  @see AsyncRangePropertyReply
71          */
72         virtual void getRangePropertyAsync(AsyncRangePropertyReply *reply) = 0;
73
74         /*!
75          * \brief setProperty is called when a sink requests to set a value for a given property.
76          * This is only called if the source supports the Set Operation (@see Operation)
77          * \param request the requested property to set.
78          * \return returns a pointer to the new value for the property.  @see AsyncPropertyReply
79          */
80         virtual AsyncPropertyReply * setProperty(AsyncSetPropertyRequest request) = 0;
81
82         /*!
83          * \brief subscribeToPropertyChanges is called when a sink requests a subscription.  Source plugins
84          * can keep track of subscriptions and may wish to sleep if there are no subscriptions.
85          * \param property the property that is being subscribed.
86          * @see unsubscribeToPropertyChanges
87          */
88         virtual void subscribeToPropertyChanges(VehicleProperty::Property property) = 0;
89
90         /*!
91          * \brief unsubscribeToPropertyChanges is called when a sink requests to unsubscribe from a given property's changes.
92          * \param property the property to unsubscribe to
93          * @see subscribeToPropertyChanges
94          */
95         virtual void unsubscribeToPropertyChanges(VehicleProperty::Property property) = 0;
96
97         /*!
98          * \brief supportedOperations
99          * \return returns the supported operations.  @see Operations
100          */
101         virtual int supportedOperations() = 0;
102
103         /*!
104          * \brief getPropertyInfo used to return specific information about a property @see PropertyInfo
105          * the source should override this otherwise a PropertyInfo::invalid() will be returned for the property
106          * \param property the property to get info for.
107          * \return a PropertyInfo object.
108          */
109         virtual PropertyInfo getPropertyInfo(const VehicleProperty::Property & property);
110         
111         /*!
112          * \brief supported
113          * \return returns the supported properties.
114          */
115         virtual PropertyList supported() = 0;
116
117 protected:
118         /*!
119          * \brief routingEngine the core routing engine used to send property updates to sink plugins.
120          * @see AbstractRoutingEngine
121          */
122         AbstractRoutingEngine* routingEngine;
123         
124 private:
125         AbstractSource():AbstractSink(nullptr, std::map<std::string,std::string>()) { }
126 };
127
128 #endif // ABSTRACTSOURCE_H