2 Copyright (C) 2012 Intel Corporation
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.
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.
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
20 #ifndef ABSTRACTSOURCE_H
21 #define ABSTRACTSOURCE_H
25 #include <boost/any.hpp>
27 #include "abstractsink.h"
28 #include "vehicleproperty.h"
29 #include "abstractroutingengine.h"
30 #include "abstractpropertytype.h"
31 #include "propertyinfo.hpp"
37 typedef std::list<AbstractSource*> SourceList;
41 class AbstractSource: public AbstractSink
46 * \brief The Operations enum is a bitmask flag used to specify which operations are supported by the source plugin
54 AbstractSource(AbstractRoutingEngine* engine, map<string, string> config);
55 virtual ~AbstractSource();
57 ///pure virtual methods:
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
64 virtual void getPropertyAsync(AsyncPropertyReply *reply) = 0;
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
72 virtual void getRangePropertyAsync(AsyncRangePropertyReply *reply) = 0;
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
80 virtual AsyncPropertyReply * setProperty(AsyncSetPropertyRequest request) = 0;
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
88 virtual void subscribeToPropertyChanges(VehicleProperty::Property property) = 0;
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
95 virtual void unsubscribeToPropertyChanges(VehicleProperty::Property property) = 0;
98 * \brief supportedOperations
99 * \return returns the supported operations. @see Operations
101 virtual int supportedOperations() = 0;
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.
109 virtual PropertyInfo getPropertyInfo(const VehicleProperty::Property & property);
113 * \return returns the supported properties.
115 virtual PropertyList supported() = 0;
119 * \brief routingEngine the core routing engine used to send property updates to sink plugins.
120 * @see AbstractRoutingEngine
122 AbstractRoutingEngine* routingEngine;
125 AbstractSource():AbstractSink(nullptr, std::map<std::string,std::string>()) { }
128 #endif // ABSTRACTSOURCE_H