2 * Copyright (C) 2011, BMW AG
4 * GeniviAudioMananger AudioManagerDaemon
8 * \date 20-Oct-2011 3:42:04 PM
9 * \author Christian Mueller (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 Mueller 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.
26 * Please make sure to have read the documentation on genivi.org!
29 //todo: add debug commandline option to allow to use other than memory database
30 //todo: make real daemon out of it- systemd conform
31 //todo: versioning of PluginInterfaces on linux level (.symver stuff)
32 //todo: all communication like all plugins loaded etc...
33 //todo: seperate documentation of test from normal project
34 //todo: check the startup sequence. Dbus shall be activated last...
35 //todo: there is a bug in the visible flags of sinks and sources. fix it.
36 //todo: check namespace handling. no use.. in headers
38 #include "DatabaseHandler.h"
39 #include "DatabaseObserver.h"
40 #include "RoutingReceiver.h"
41 #include "CommandReceiver.h"
42 #include "ControlReceiver.h"
43 #include "ControlSender.h"
44 #include "CommandSender.h"
45 #include "RoutingSender.h"
46 #include "DBusWrapper.h"
48 #include <dbus/dbus.h>
51 DLT_DECLARE_CONTEXT(DLT_CONTEXT)
55 #define DEFAULT_PLUGIN_COMMAND_DIR "/home/christian/workspace/gitserver/build/plugins/command"
56 #define DEFAULT_PLUGIN_ROUTING_DIR "/home/christian/workspace/gitserver/build/plugins/routing"
57 #define CONTROLLER_PLUGIN "/home/christian/workspace/gitserver/build/plugins/control/libPluginControlInterface.so"
59 int main(int argc, char *argv[])
61 DLT_REGISTER_APP("AudioManagerDeamon","AudioManagerDeamon");
62 DLT_REGISTER_CONTEXT(DLT_CONTEXT,"Main","Main Context");
63 DLT_LOG(DLT_CONTEXT,DLT_LOG_INFO, DLT_STRING("The AudioManager is started "));
65 std::vector<std::string> listCommandPluginDirs;
66 listCommandPluginDirs.push_back(std::string(DEFAULT_PLUGIN_COMMAND_DIR)); //change this to be modified by the commandline!
68 std::vector<std::string> listRoutingPluginDirs;
69 listRoutingPluginDirs.push_back(std::string(DEFAULT_PLUGIN_ROUTING_DIR)); //change this to be modified by the commandline!
71 //Instantiate all classes. Keep in same order !
72 DatabaseHandler iDatabaseHandler(std::string(":memory:"));
73 DBusWrapper iDBusWrapper;
74 RoutingSender iRoutingSender(listRoutingPluginDirs);
75 CommandSender iCommandSender(listCommandPluginDirs);
76 ControlSender iControlSender(std::string(CONTROLLER_PLUGIN));
77 DatabaseObserver iObserver(&iCommandSender, &iRoutingSender);
78 CommandReceiver iCommandReceiver(&iDatabaseHandler,&iDBusWrapper,&iControlSender);
79 RoutingReceiver iRoutingReceiver(&iDatabaseHandler,&iRoutingSender,&iControlSender);
80 ControlReceiver iControlReceiver(&iDatabaseHandler,&iRoutingSender,&iCommandSender);
82 //since the plugins have been loaded by the *Senders before, we can tell the Controller this:
83 iControlSender.hookAllPluginsLoaded();
85 //the controller should startup the interfaces - this is just for testing
86 iCommandSender.startupInterface(&iCommandReceiver);
87 iRoutingSender.startupRoutingInterface(&iRoutingReceiver);
90 iDBusWrapper.dbusMainLoop();