2 * Copyright (C) 2011, BMW AG
9 * \author Christian Müller (christian.ei.mueller@bmw.de)
12 * GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
13 * Copyright (C) 2011, BMW AG – Christian Müller Christian.ei.mueller@bmw.de
15 * This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
16 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
17 * You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
18 * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
19 * Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
20 * As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
21 * Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
29 #include "audioManagerIncludes.h"
31 class DataBaseHandler;
32 class RoutingReceiver;
33 class AudioManagerCore;
35 /**calculates routes from sinks to sources
36 * navigation for audio
43 /**Registers the database handler
45 * @param db_handler pointer to dabase handler
47 void registerDatabasehandler(DataBaseHandler* db_handler);
49 /**the routing algorithm. Returns a list of routes
51 * @param onlyfree true if only free gateways shall be used
52 * @param Source_ID the source ID from wich the route should start
53 * @param Sink_ID the sink ID where the route should end
54 * @param ReturnList buffer for the answer.
55 * @return returns true on success
57 bool get_Route_from_Source_ID_to_Sink_ID(const bool onlyfree,
58 const source_t Source_ID, const sink_t Sink_ID,
59 std::list<genRoute_t>* ReturnList);
62 DataBaseHandler* m_dbHandler;
65 /**This represents one Item in the RoutingTree
68 class RoutingTreeItem {
71 virtual ~RoutingTreeItem();
73 /**overloaded Constructor
75 * @param Domain_Id the domain ID where the gateway ends
76 * @param Gateway_Id the gateway ID that connects the domains
77 * @param parent pointer to the parent item in the tree
79 RoutingTreeItem(const domain_t Domain_Id, const gateway_t Gateway_Id = 0,
80 RoutingTreeItem *parent = 0);
82 /**appends a child from the same type to the tree
86 void appendChild(RoutingTreeItem *child);
88 /**returns a list of all child items
90 * @param ChildItems buffer for the child items
92 void returnChildItems(std::list<RoutingTreeItem*> ChildItems);
94 /**returns the domain ID
96 * @return the domain ID
98 domain_t returnDomainID();
100 /**returns the gateway ID
104 gateway_t returnGatewayID(void);
106 /** is used to retrieve the parent item
108 * @return pointer to parent RoutingTreeItem
110 RoutingTreeItem* return_Parent();
113 std::list<RoutingTreeItem*> childItems; //!< List of all child items
114 domain_t m_domainID; //!< the domain ID of the item
115 gateway_t m_gatewayID; //!< the gateway Id
116 RoutingTreeItem *parentItem; //!< pointer to the parent item
119 /**The routing tree iself
125 /**constructor must always be called with the root domain ID
127 * @param Root_Domain_ID
129 RoutingTree(const domain_t Root_Domain_ID);
132 /**Insert an item in the Tree with the parent parentItem
134 * @param Domain_ID the domain Id
135 * @param Gateway_ID the gateway ID
136 * @param parentItem pointer to the parent Item
137 * @return returns a pointer to the new item
139 RoutingTreeItem* insertItem(const domain_t Domain_ID,
140 const gateway_t Gateway_ID, RoutingTreeItem* parentItem);
142 /**reverses the tree to get a route to the TargetItem
144 * @param TargetItem pointer to the Item from which should be reversed
145 * @param route pointer to a list of gateway IDs that need to be connected
146 * @return the length of the route.
148 int getRoute(RoutingTreeItem* TargetItem, std::list<gateway_t>* route);
150 /**returns the DomainId of the rootItem
152 * @return domain ID of the root Item
154 domain_t returnRootDomainID(void);
156 /**returns a pointer to the rootitem
158 * @return pointer to the rootitem
160 RoutingTreeItem* returnRootItem(void);
163 RoutingTreeItem m_rootItem; //!< pointer to root item
164 std::list<RoutingTreeItem*> m_allChildList; //!< list of all childs
167 /**This class is responsible for loading the RoutingInterface Plugins
168 * In order to let a plugin be loaded by the BusManager, just add it in main.cpp like this
169 * @code Q_IMPORT_PLUGIN(RoutingPlugin) @code
175 virtual ~Bushandler() {};
177 /**by calling this, all bus plugins are loaded
180 void load_Bus_plugins();
182 /**needed to register the m_receiver Instance
183 * via this function the receiver instance is given to the plugins so that they can call methods to talk to the audiomanager
184 * @param m_receiver pointer to the receiver
186 void registerReceiver(RoutingReceiver* Receiver);
188 void registerCore (AudioManagerCore* core);
190 /**By calling this function the plugins are called to startup.
191 * Init functions etc are done by the plugins in this phase
193 void StartupInterfaces();
195 /**This function returns the pointer to the actual interface for a Bus
197 * @param bus the name of the bus
198 * @return pointer to the interface
200 RoutingSendInterface* getInterfaceforBus(std::string bus);
202 /**This signal informs the plugins that the AudioManager is ready to register Domains Sinks and Sources
205 void signal_system_ready(void);
208 /**Struct to save Name and Interface together
212 RoutingSendInterface* sendInterface;
216 std::list<Bus> Busses; //!< list of all busses
217 RoutingReceiver* m_receiver; //!< pointer to the routing receiver
218 AudioManagerCore* m_core;
221 #endif /* ROUTER_H_ */