00001 /*************************************************************************** 00002 * Copyright (C) 2005 by Benjamin Hadorn (bhadorn@swissinfo.org) * 00003 *************************************************************************** 00004 * Projekt : Zeus 00005 * Module : ModuleFunctions 00006 * Package : MOM 00007 * Author : Benjamin Hadorn 00008 * Datum : $Date: 3.11.09 16:01 $ 00009 * Ablage : $File$ 00010 * System : Cell Computing Model 00011 *************************************************************************** 00012 * Licence: * 00013 * This library is free software; you can redistribute it and/or modify * 00014 * it under the terms of the GNU Lesser General Public License as * 00015 * published by the Free Software Foundation; either version * 00016 * 2.1 of the License, or (at your option) any later version. * 00017 * * 00018 * This library is distributed in the hope that it will be useful, * 00019 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00020 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00021 * GNU Lesser General Public License for more details. * 00022 * * 00023 * You should have received a copy of the GNU Lesser General Public * 00024 * License along with this library; if not, write to the Free Software * 00025 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA * 00026 ***************************************************************************/ 00027 00028 /*************************************************************************** 00029 Changes : 00030 $Log: /Development_F/StuderWIN/dev/Zeus/src/zeusbase/MOM/ModuleFunctions.hpp $ 00031 ** 00032 ** 12 3.11.09 16:01 Bha 00033 ** comments corrected 00034 ** 00035 ** 11 26.02.07 9:00 bha 00036 ** 00037 ** 8 20.10.06 10:23 bha 00038 ** Redesign of IXObject interface 00039 ***************************************************************************/ 00040 00041 #ifndef ModuleFunctionsHPP 00042 #define ModuleFunctionsHPP 00043 00044 #include <zeusbase/MOM/Module.h> 00045 #include <zeusbase/MOM/Interfaces/IModule.hpp> 00046 00047 00048 BEGIN_NAMESPACE_Zeus 00049 00050 00051 /*************************************************************************/ 00055 /*************************************************************************/ 00056 template <class TModuleType> class TModuleFunctions 00057 { 00058 public: 00059 00060 /*************************************************************************/ 00065 /*************************************************************************/ 00066 static void activateFirstChild(TModuleType& rMod, bool& rActiveFlag) 00067 { 00068 Int iCount = rMod.getChildCount(); 00069 bool bFound = false; 00070 IXObject* pObject = NULL; 00071 IModule* pModule = NULL; 00072 for(Int i = 0; i < iCount && !bFound; i++) 00073 { 00074 if (rMod.getChild(i, pObject) == RET_NOERROR) 00075 { 00076 if (pObject->askForInterface(INTERFACE_IModule, ICAST(pModule)) == RET_NOERROR) 00077 { 00079 //Secure code: The flag must be set befor calling the activate() method 00080 rActiveFlag = true; 00082 00083 pModule->activate(); 00084 pModule->release(); 00085 bFound = true; 00086 } 00087 pObject->release(); 00088 } 00089 } 00090 } 00091 00092 /***************************************************************************/ 00095 /***************************************************************************/ 00096 static Retval getModule(TModuleType& rMod, const IString& rName, IModule*& rpModule) 00097 { 00098 Retval retValue = RET_REQUEST_FAILED; 00099 IXObject* pObject = NULL; 00100 retValue = rMod.getObject(rName, pObject); 00101 if (retValue == RET_NOERROR) 00102 { 00103 if (pObject->askForInterface(INTERFACE_IModule, ICAST(rpModule)) == RET_NOERROR) 00104 { 00105 retValue = RET_NOERROR; 00106 } 00107 else 00108 { 00109 retValue = RET_REQUEST_FAILED; 00110 } 00111 pObject->release(); 00112 } 00113 return retValue; 00114 } 00115 00116 }; 00117 00118 00119 END_NAMESPACE_Zeus 00120 00121 #endif