Kevin Rocard | ee7ceed | 2013-07-05 10:56:27 +0200 | [diff] [blame] | 1 | /* |
David Wagner | b76c9d6 | 2014-02-05 18:30:24 +0100 | [diff] [blame] | 2 | * Copyright (c) 2011-2014, Intel Corporation |
| 3 | * All rights reserved. |
Kevin Rocard | ee7ceed | 2013-07-05 10:56:27 +0200 | [diff] [blame] | 4 | * |
David Wagner | b76c9d6 | 2014-02-05 18:30:24 +0100 | [diff] [blame] | 5 | * Redistribution and use in source and binary forms, with or without modification, |
| 6 | * are permitted provided that the following conditions are met: |
Kevin Rocard | ee7ceed | 2013-07-05 10:56:27 +0200 | [diff] [blame] | 7 | * |
David Wagner | b76c9d6 | 2014-02-05 18:30:24 +0100 | [diff] [blame] | 8 | * 1. Redistributions of source code must retain the above copyright notice, this |
| 9 | * list of conditions and the following disclaimer. |
Kevin Rocard | ee7ceed | 2013-07-05 10:56:27 +0200 | [diff] [blame] | 10 | * |
David Wagner | b76c9d6 | 2014-02-05 18:30:24 +0100 | [diff] [blame] | 11 | * 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 Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 29 | */ |
| 30 | #pragma once |
| 31 | |
| 32 | #include "ConfigurableElement.h" |
Guillaume Denneulin | a4ec15d | 2012-02-17 14:38:14 +0100 | [diff] [blame] | 33 | #include "SubsystemPlugins.h" |
Patrick Benavoli | 9bed7ce | 2011-11-20 20:04:35 +0100 | [diff] [blame] | 34 | #include <list> |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 35 | |
| 36 | class CSubsystemLibrary; |
| 37 | |
| 38 | class CSystemClass : public CConfigurableElement |
| 39 | { |
| 40 | public: |
Patrick Benavoli | 95ac034 | 2011-11-07 20:32:51 +0100 | [diff] [blame] | 41 | CSystemClass(); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 42 | virtual ~CSystemClass(); |
| 43 | |
Kevin Rocard | ee7ceed | 2013-07-05 10:56:27 +0200 | [diff] [blame] | 44 | /** 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 Denneulin | a4ec15d | 2012-02-17 14:38:14 +0100 | [diff] [blame] | 56 | // Subsystem factory |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 57 | const CSubsystemLibrary* getSubsystemLibrary() const; |
| 58 | |
Kevin Rocard | 2fbe6e8 | 2013-03-26 17:09:29 +0100 | [diff] [blame] | 59 | /** |
| 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 Denneulin | f2fd15a | 2012-12-20 17:53:29 +0100 | [diff] [blame] | 66 | void checkForSubsystemsToResync(CSyncerSet& syncerSet); |
| 67 | |
Kevin Rocard | 2fbe6e8 | 2013-03-26 17:09:29 +0100 | [diff] [blame] | 68 | /** |
| 69 | * Reset subsystems need to resync flag. |
| 70 | */ |
| 71 | void cleanSubsystemsNeedToResync(); |
| 72 | |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 73 | // base |
| 74 | virtual bool init(string& strError); |
| 75 | virtual string getKind() const; |
| 76 | |
Georges-Henri Baron | 326a31d | 2012-06-28 12:05:09 +0200 | [diff] [blame] | 77 | // From IXmlSource |
| 78 | virtual void toXml(CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) const; |
| 79 | |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 80 | private: |
JhinX Lee | 4ebc098 | 2012-07-12 17:50:07 +0200 | [diff] [blame] | 81 | CSystemClass(const CSystemClass&); |
| 82 | CSystemClass& operator=(const CSystemClass&); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 83 | // base |
| 84 | virtual bool childrenAreDynamic() const; |
| 85 | |
Kevin Rocard | 6be8035 | 2013-07-11 12:42:23 +0200 | [diff] [blame] | 86 | /** 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 Benavoli | 9bed7ce | 2011-11-20 20:04:35 +0100 | [diff] [blame] | 96 | // Plugin symbol computation |
| 97 | static string getPluginSymbol(const string& strPluginPath); |
| 98 | |
Kevin Rocard | ee7ceed | 2013-07-05 10:56:27 +0200 | [diff] [blame] | 99 | /** 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 Rocard | 6be8035 | 2013-07-11 12:42:23 +0200 | [diff] [blame] | 106 | * When false is returned, some plugins MIHGT have been loaded |
| 107 | * but the lstrPluginFiles is accurate. |
Kevin Rocard | ee7ceed | 2013-07-05 10:56:27 +0200 | [diff] [blame] | 108 | */ |
| 109 | bool loadPlugins(list<string>& lstrPluginFiles, list<string>& lstrError); |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 110 | |
Guillaume Denneulin | a4ec15d | 2012-02-17 14:38:14 +0100 | [diff] [blame] | 111 | // Subsystem factory |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 112 | CSubsystemLibrary* _pSubsystemLibrary; |
Renaud de Chivre | 1b8b3ca | 2013-12-13 15:09:44 +0100 | [diff] [blame] | 113 | list<void*> _subsystemLibraries; /**< Contains the list of all open plugin libs. */ |
Patrick Benavoli | 68a9128 | 2011-08-31 11:23:23 +0200 | [diff] [blame] | 114 | }; |
| 115 | |