void Settings::load() { utils::parsing::FileStream fs(_filename); _ini = utils::ini::ReadIni(fs, "core").parse(); const utils::ini::Ini::Section& moduleSection = _ini["modules"]; std::list< utils::ini::Ini::Section::Instruction >::const_iterator it; std::list< std::string >::const_iterator itargs; for (it = moduleSection.instructions().begin(); it != moduleSection.instructions().end(); ++it) if (it->instr() == "add") { const std::string* url = 0; const std::string* sigInput = 0; const std::string* sigOutput = 0; for (itargs = it->args().begin(); itargs != it->args().end(); ++itargs) { if (!url) url = &*itargs; else if (!sigInput && (*itargs)[0] == '<') sigInput = &*itargs; else if (!sigOutput && (*itargs)[0] == '>') sigOutput = &*itargs; } // if (url && sigInput && sigOutput) // _modulesInfos.push_back(ModuleInfo(*url, *sigInput, *sigOutput, it->kwargs())); if (url) _modulesInfos.push_back(ModuleInfo(*url, (sigInput ? *sigInput : _nullSig), (sigOutput ? *sigOutput : _nullSig), it->kwargs())); else throw Exception("load: Incomplete add instruction"); } }
ErrorCode ComponentManager::LoadLibrary( const char *name ) { TRACE_BEGIN( LOG_LVL_INFO ); IModule *mod = NULL; ErrorCode result = kNoError; LOG_NOTICE( "Opening Library: %s", name ); ErrorCode (*LoadLibrary)( IComponentManager *mgr ); IModule *(*GetModule)(); void *handle = dlopen( name, RTLD_LAZY ); if ( handle == NULL ) { result = kLoadFailed; LOG_WARN( "Failed to open shared lib \"%s\": %s", name, dlerror() ); } else { LoadLibrary = (ErrorCode (*)(IComponentManager *mgr))dlsym( handle, "JHCOM_LibraryEntry" ); GetModule = (IModule *(*)())dlsym( handle, "JHCOM_GetModule" ); if ( GetModule == NULL || LoadLibrary == NULL ) { result = kLoadFailed; LOG_WARN( "Failed to get symbol" ); } else { LOG( "LoadLibrary is %p", LoadLibrary ); LOG( "RegisterServices is %p", GetModule ); result = LoadLibrary( this ); if ( result == kNoError ) { mod = GetModule(); mod->AddRef(); mod->loadComponents(); ModuleInfo *info = jh_new ModuleInfo( name, mod, handle ); mModules.push_back( info ); } } } return result; }
ModuleInfo parseModuleInfo(const utils::Buffer& buf) { utils::StructReader sr(reinterpret_cast<const char*>(buf.getPtr())); try { std::string name = sr.getStringValue("gui_name"); std::string identifier = sr.getStringValue("identifier"); std::string group = sr.getStringValue("group"); std::string inputs = sr.getStringValue("inputs"); std::string outputs = sr.getStringValue("outputs"); std::string moduleType = sr.getStringValue("type"); try { std::vector<PlugInfo> ins = processArray(inputs); std::vector<PlugInfo> outs = processArray(outputs); if (moduleType == "xpm") { const char* ptr = reinterpret_cast<const char*>(buf.getPtr()); const char* offset = ptr + strlen(ptr) + 1; int newLen = buf.getLen() - strlen(ptr) - 1; utils::AutoPtr<Xpm> xpm(new Xpm(offset,newLen)); return ModuleInfo(identifier,name,group,ins,outs,xpm); } else { throw std::runtime_error("MUIltkj"); } } catch (std::logic_error&) { std::cerr << "Buffer = <" << buf.getPtr() << ">" << std::endl; } } catch (std::runtime_error& e) { std::string msg = "Fehler beim Parsen der ModulInfo: "; msg += e.what(); throw std::runtime_error(msg.c_str()); } }
void FModuleManager::AddModule(const FName InModuleName) { // Do we already know about this module? If not, we'll create information for this module now. if (!((ensureMsg(InModuleName != NAME_None, TEXT("FModuleManager::AddModule() was called with an invalid module name (empty string or 'None'.) This is not allowed.")) && !Modules.Contains(InModuleName)))) { return; } TSharedRef<FModuleInfo> ModuleInfo(new FModuleInfo()); // Make sure module info is added to known modules and proper delegates are fired on exit. ON_SCOPE_EXIT { FModuleManager::Get().AddModuleToModulesList(InModuleName, ModuleInfo); }; #if !IS_MONOLITHIC FString ModuleNameString = InModuleName.ToString(); TMap<FName, FString> ModulePathMap; FindModulePaths(*ModuleNameString, ModulePathMap); if (ModulePathMap.Num() != 1) { return; } // Add this module to the set of modules that we know about ModuleInfo->OriginalFilename = TMap<FName, FString>::TConstIterator(ModulePathMap).Value(); ModuleInfo->Filename = ModuleInfo->OriginalFilename; // When iterating on code during development, it's possible there are multiple rolling versions of this // module's DLL file. This can happen if the programmer is recompiling DLLs while the game is loaded. In // this case, we want to load the newest iteration of the DLL file, so that behavior is the same after // restarting the application. // NOTE: We leave this enabled in UE_BUILD_SHIPPING editor builds so module authors can iterate on custom modules #if !(UE_BUILD_SHIPPING || UE_BUILD_TEST) || (UE_BUILD_SHIPPING && WITH_EDITOR) // In some cases, sadly, modules may be loaded before appInit() is called. We can't cleanly support rolling files for those modules. // First, check to see if the module we added already exists on disk const FDateTime OriginalModuleFileTime = IFileManager::Get().GetTimeStamp(*ModuleInfo->OriginalFilename); if (OriginalModuleFileTime == FDateTime::MinValue()) { return; } const FString ModuleName = *InModuleName.ToString(); const int32 MatchPos = ModuleInfo->OriginalFilename.Find(ModuleName, ESearchCase::IgnoreCase, ESearchDir::FromEnd); if (!ensureMsgf(MatchPos != INDEX_NONE, TEXT("Could not find module name '%s' in module filename '%s'"), *ModuleName, *ModuleInfo->OriginalFilename)) { return; } const int32 SuffixPos = MatchPos + ModuleName.Len(); const FString Prefix = ModuleInfo->OriginalFilename.Left(SuffixPos); const FString Suffix = ModuleInfo->OriginalFilename.Right(ModuleInfo->OriginalFilename.Len() - SuffixPos); const FString ModuleFileSearchString = FString::Printf(TEXT("%s-*%s"), *Prefix, *Suffix); // Search for module files TArray<FString> FoundFiles; IFileManager::Get().FindFiles(FoundFiles, *ModuleFileSearchString, true, false); if (FoundFiles.Num() == 0) { return; } const FString ModuleFileSearchDirectory = FPaths::GetPath(ModuleFileSearchString); FString NewestModuleFilename; bool bFoundNewestFile = FindNewestModuleFile(FoundFiles, OriginalModuleFileTime, ModuleFileSearchDirectory, Prefix, Suffix, NewestModuleFilename); // Did we find a variant of the module file that is newer than our original file? if (!bFoundNewestFile) { // No variants were found that were newer than the original module file name, so // we'll continue to use that! return; } // Update the module working file name to the most recently-modified copy of that module const FString NewestModuleFilePath = ModuleFileSearchDirectory.IsEmpty() ? NewestModuleFilename : (ModuleFileSearchDirectory / NewestModuleFilename); ModuleInfo->Filename = NewestModuleFilePath; #endif // !(UE_BUILD_SHIPPING || UE_BUILD_TEST) #endif // !IS_MONOLITHIC }