blob: b4b44e5a9c857a40980a7d255881c33498a10287 [file] [log] [blame]
Kevin Rocardee7ceed2013-07-05 10:56:27 +02001/*
David Wagnerb76c9d62014-02-05 18:30:24 +01002 * Copyright (c) 2011-2014, Intel Corporation
3 * All rights reserved.
Kevin Rocardee7ceed2013-07-05 10:56:27 +02004 *
David Wagnerb76c9d62014-02-05 18:30:24 +01005 * Redistribution and use in source and binary forms, with or without modification,
6 * are permitted provided that the following conditions are met:
Kevin Rocardee7ceed2013-07-05 10:56:27 +02007 *
David Wagnerb76c9d62014-02-05 18:30:24 +01008 * 1. Redistributions of source code must retain the above copyright notice, this
9 * list of conditions and the following disclaimer.
Kevin Rocardee7ceed2013-07-05 10:56:27 +020010 *
David Wagnerb76c9d62014-02-05 18:30:24 +010011 * 2. Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation and/or
13 * other materials provided with the distribution.
14 *
15 * 3. Neither the name of the copyright holder nor the names of its contributors
16 * may be used to endorse or promote products derived from this software without
17 * specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
23 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Patrick Benavoli68a91282011-08-31 11:23:23 +020029 */
30#pragma once
31
32#include "ConfigurableElement.h"
Guillaume Denneulina4ec15d2012-02-17 14:38:14 +010033#include "SubsystemPlugins.h"
Patrick Benavoli9bed7ce2011-11-20 20:04:35 +010034#include <list>
Patrick Benavoli68a91282011-08-31 11:23:23 +020035
36class CSubsystemLibrary;
37
38class CSystemClass : public CConfigurableElement
39{
40public:
Patrick Benavoli95ac0342011-11-07 20:32:51 +010041 CSystemClass();
Patrick Benavoli68a91282011-08-31 11:23:23 +020042 virtual ~CSystemClass();
43
Kevin Rocardee7ceed2013-07-05 10:56:27 +020044 /** Load subsystem plugin and fill the corresponding libraries.
45 *
46 * @param[out] strError is filled with new line separated errors if the function returns false,
47 * undefined otherwise.
48 * @param[in] pSubsystemPlugins The plugins to load.
49 * @param[in] bVirtualSubsystemFallback If a subsystem can not be found, use the virtual one.
50 *
51 * @return true if the plugins succesfully started or that a fallback is available,
52 false otherwise.
53 */
54 bool loadSubsystems(string& strError, const CSubsystemPlugins* pSubsystemPlugins,
55 bool bVirtualSubsystemFallback = false);
Guillaume Denneulina4ec15d2012-02-17 14:38:14 +010056 // Subsystem factory
Patrick Benavoli68a91282011-08-31 11:23:23 +020057 const CSubsystemLibrary* getSubsystemLibrary() const;
58
Kevin Rocard2fbe6e82013-03-26 17:09:29 +010059 /**
60 * Look for subsystems that need to be resynchronized.
61 * Consume the need to be resynchronized
62 * and fill a syncer set with all syncers that need to be resynchronized
63 *
64 * @param[out] syncerSet The syncer set to fill
65 */
Guillaume Denneulinf2fd15a2012-12-20 17:53:29 +010066 void checkForSubsystemsToResync(CSyncerSet& syncerSet);
67
Kevin Rocard2fbe6e82013-03-26 17:09:29 +010068 /**
69 * Reset subsystems need to resync flag.
70 */
71 void cleanSubsystemsNeedToResync();
72
Patrick Benavoli68a91282011-08-31 11:23:23 +020073 // base
74 virtual bool init(string& strError);
75 virtual string getKind() const;
76
Georges-Henri Baron326a31d2012-06-28 12:05:09 +020077 // From IXmlSource
78 virtual void toXml(CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) const;
79
Patrick Benavoli68a91282011-08-31 11:23:23 +020080private:
JhinX Lee4ebc0982012-07-12 17:50:07 +020081 CSystemClass(const CSystemClass&);
82 CSystemClass& operator=(const CSystemClass&);
Patrick Benavoli68a91282011-08-31 11:23:23 +020083 // base
84 virtual bool childrenAreDynamic() const;
85
Kevin Rocard6be80352013-07-11 12:42:23 +020086 /** Load shared libraries subsystem plugins.
87 *
88 * @param[out] lstrError is the list of error that occured during loadings.
89 * @param[in] pSubsystemPlugins The plugins to load.
90 *
91 * @return true if all plugins have been succesfully loaded, false otherwises.
92 */
93 bool loadSubsystemsFromSharedLibraries(list<string>& lstrError,
94 const CSubsystemPlugins* pSubsystemPlugins);
95
Patrick Benavoli9bed7ce2011-11-20 20:04:35 +010096 // Plugin symbol computation
97 static string getPluginSymbol(const string& strPluginPath);
98
Kevin Rocardee7ceed2013-07-05 10:56:27 +020099 /** Load subsystem plugin shared libraries.
100 *
101 * @param[in:out] lstrPluginFiles is the path list of the plugins shared libraries to load.
102 * Successfully loaded plugins are removed from the list.
103 * @param[out] lstrError is the list of error that occured during loadings.
104 *
105 * @return true if at least one plugin has been succesfully loaded, false otherwise.
Kevin Rocard6be80352013-07-11 12:42:23 +0200106 * When false is returned, some plugins MIHGT have been loaded
107 * but the lstrPluginFiles is accurate.
Kevin Rocardee7ceed2013-07-05 10:56:27 +0200108 */
109 bool loadPlugins(list<string>& lstrPluginFiles, list<string>& lstrError);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200110
Guillaume Denneulina4ec15d2012-02-17 14:38:14 +0100111 // Subsystem factory
Patrick Benavoli68a91282011-08-31 11:23:23 +0200112 CSubsystemLibrary* _pSubsystemLibrary;
Renaud de Chivre1b8b3ca2013-12-13 15:09:44 +0100113 list<void*> _subsystemLibraries; /**< Contains the list of all open plugin libs. */
Patrick Benavoli68a91282011-08-31 11:23:23 +0200114};
115