예제 #1
0
파일: e6.cpp 프로젝트: berak/e6
		virtual uint findInterfaces( const char * interfaceName, InterfaceCallback & finder )
		{
			uint n = 0;
			for ( ModIter it = mods.begin(); it != mods.end(); ++it )
			{
				const char * s = it->first;
				Dll * d  = it->second;
				ClassInfo *info = d->getClassInfo();
				while ( info && info->iname )
				{
					if ( ! strcmp( interfaceName, "*" ) ) // selected 'All'
					{
						uint r = finder.call( info->iname, info->cname, info->count() );
						n ++;
					}
					else
					if ( ! strcmp( interfaceName, info->iname ) )
					{
						uint r = finder.call( info->iname, info->cname, info->count() );
						n ++;
					}
					++ info;
				}
			}
			return n;
		}
예제 #2
0
파일: e6.cpp 프로젝트: berak/e6
		virtual uint cleanupModules() 
		{
			std::vector<ModIter> undead;
			for ( ModIter it = mods.begin(); it != mods.end(); ++it )
			{
				uint n = 0;
				const char * s = it->first;
				Dll * d  = it->second;
				ClassInfo *info = d->getClassInfo();
				while ( info && info->iname )
				{
					n += info->count();				
					++info;
				}
				if ( n==0 )
				{
					printf( "undead : %s\n", s );
					undead.push_back( it );
				}
			}
			for ( uint i=0; i<undead.size(); i++ )
			{
				ModIter it = undead[i];
				printf( "kill : %s\n", it->first );
				Dll * d  = it->second;
				E_DELETE( d );
				mods.erase( it );
			}
			return 1;
		}
예제 #3
0
파일: e6.cpp 프로젝트: berak/e6
		virtual ~CEngine() 
		{
			$X1("del()");

			for ( ModIter it = mods.begin(); it != mods.end(); ++it )
			{
				const char * s = it->first;
				Dll * d  = it->second;
				ClassInfo *info = d->getClassInfo();
				char b[300];
				char b1[1024];
				bool alive=0;
				b[0] = b1[0] = 0;
				while ( info->iname )
				{
					if ( info->count() )
					{
						alive=1;
						sprintf( b, "%s %i instances of %s alive !\n", info->cname, info->count(), info->iname );
						strcat( b1, b );
					}
					++info;
				}
				if ( alive )
					sys::alert("ref trouble !", b1 );
				E_DELETE( d );
			}
		}
예제 #4
0
파일: e6.cpp 프로젝트: berak/e6
		void showRegistry()
		{
			std::cerr << "Registry (" << mods.size() << " modules) : "<< e6_version <<"\n";
			for ( ModIter it = mods.begin(); it != mods.end(); ++it )
			{
				const char * s = it->first;
				Dll * d  = it->second;
				showDll( d, s );
			}
		}
예제 #5
0
파일: e6.cpp 프로젝트: berak/e6
		virtual void * createInterface( const char * moduleName,  const char * interfaceName )
		{
			E_ASSERT(moduleName);
			E_ASSERT(interfaceName);
			// std::cerr << __FUNCTION__ << " (" << moduleName << ", " << interfaceName << ")\n";
			ModIter it = mods.find( moduleName );
			bool found = 0;
			do // once
			{
				if ( it != mods.end() )
				{
					found = true;
					break;
				}

				if ( ! loadDll ( moduleName ) )
				{
				//	sys::alert( __FUNCTION__,  "mod not found %s :: %s", moduleName, interfaceName );
					break;
				}
				it = mods.find( moduleName );
				if ( it == mods.end() )
				{
					sys::alert( __FUNCTION__,  "mod not inserted %s :: %s", moduleName, interfaceName );
					break;
				}

				found = true;
			} while(0); // do once

			if ( ! found ) 
			{
				return 0;
			}

			Dll* h = it->second;
			ClassInfo * info = h->getClassInfo( );
			if ( ! info )
			{
				sys::alert( __FUNCTION__, "ClassInfo not found %s :: %s", moduleName, interfaceName );
				return 0;
			}
	
			while ( info && info->cname )
			{
				if ( ! strcmp( info->iname, interfaceName ) )
				{
					return info->create();
				}
				++ info;
			}
	
			sys::alert( __FUNCTION__, "could not create %s :: %s", moduleName, interfaceName );
			return 0;
		}
예제 #6
0
파일: e6.cpp 프로젝트: berak/e6
		uint unloadDll( const char *moduleName )
		{
			$X1("unload (" << moduleName << ")" );
			ModIter it = mods.find( moduleName );
			if ( it != mods.end() )
			{
				Dll* h = it->second;
				E_DELETE( h );
				return 1;
			}
			return 0;
		}
예제 #7
0
파일: e6.cpp 프로젝트: berak/e6
		Dll * loadDll( const char *moduleName )
		{
			E_ASSERT( moduleName );

			char binPath[300];
			sprintf( binPath, "%s%cbin", e6Path, sys::fileSeparator() ); 
			const char * oldPath = sys::getCurrentDir();
			sys::setCurrentDir( binPath );

			$X1("load (" << moduleName << ")" );
			Dll * dll = new Dll;
			if ( ! dll->open( moduleName ) )
			{
				delete dll;
				sys::setCurrentDir( oldPath );
				return 0;
			}
	
			strcpy( dll->moduleName, moduleName );
			mods.insert( std::make_pair( dll->moduleName, dll ) );

			// reset
			sys::setCurrentDir( oldPath );

			return dll;
		}
예제 #8
0
void BookTreeCtrl::RefreshBookList(bool ShowLanguages)
{
  using namespace sword;

  ModMap::iterator it;
  SWModule *curMod = 0;
  ModMap *Modules;

  Modules = m_SwordTools->GetModuleMap();
  wxTreeItemId rootnode,
  childnode,
  langnode,
  curNode;

  std::map < string, wxTreeItemId > treenodes;
  std::map < string, wxTreeItemId > treelangnodes;

  string group,
  grouplang;

  wxString configEntry;

  rootnode = AddRoot(wxT("books"));
  for (it = Modules->begin(); it != Modules->end(); it++)
  {
    curMod = (*it).second;

    if (curMod == 0) {
      continue;
    }

    wxLogDebug(wxT("type %s"),
               (const wxChar *) wxString(curMod->Type(), wxConvUTF8));

    configEntry = wxT("");
    configEntry = wxString(curMod->getConfigEntry("Category"), wxConvUTF8);
    if (!configEntry.CompareTo(wxT("")))
    {
      childnode = treenodes[curMod->Type()];
      if (!childnode.IsOk())
      {
        wxLogDebug(wxT("appending type"));
        childnode =
          AppendItem(rootnode, wxString(curMod->Type(), wxConvUTF8),
                     ID_CLOSEDFOLDER_ICON, ID_CLOSEDFOLDER_ICON);
        treenodes[curMod->Type()] = childnode;
      }

      group = curMod->Type();
    }
    else
    {
      childnode = treenodes[(const char *) configEntry.mb_str()];
      if (!childnode.IsOk())
      {
        childnode =
          AppendItem(rootnode, configEntry, ID_CLOSEDFOLDER_ICON,
                     ID_CLOSEDFOLDER_ICON);
        treenodes[(const char *) configEntry.mb_str()] = childnode;
      }

      curMod->Type((const char *) configEntry.mb_str());
      group = (const char *) configEntry.mb_str();
    }

    grouplang = group;
    wxLogDebug(wxT("language %s"),
               (const wxChar *) wxString(curMod->Lang(), wxConvUTF8));
    grouplang.append(curMod->Lang());

    if (ShowLanguages)
    {
      langnode = treelangnodes[grouplang];
      if (!langnode.IsOk())
      {
        wxString language;

        wxLogDebug(wxT("appending language"));

        language =
          m_Languages.GetLanguage(wxString(curMod->Lang(), wxConvUTF8));

        langnode =
          AppendItem(childnode, language, ID_CLOSEDFOLDER_ICON,
                     ID_CLOSEDFOLDER_ICON);

        treelangnodes[grouplang] = langnode;
      }
    }
    else
    {
      langnode = childnode;
    }

    wxString modname = wxString(curMod->Name(), wxConvUTF8);

    modname += wxT(" - ");
    modname += wxString(curMod->Description(), wxConvUTF8);
    wxLogDebug(wxT("appending module %s"), (const wxChar *) modname);

    /** SET ICON **/
    if (!strcmp(curMod->Type(), "Biblical Texts"))
    {
      curNode =
        AppendItem(langnode,
                   wxString(curMod->Name(),
                            wxConvUTF8) + wxT(" - ") +
                   wxString(curMod->Description(), wxConvUTF8),
                   ID_BIBLICAL_TEXT_ICON, ID_BIBLICAL_TEXT_ICON);
    }
    else if (!strcmp(curMod->Type(), "Lexicons / Dictionaries")
             || !strcmp(curMod->Type(), "Glossaries"))
    {
      curNode =
        AppendItem(langnode,
                   wxString(curMod->Name(),
                            wxConvUTF8) + wxT(" - ") +
                   wxString(curMod->Description(), wxConvUTF8), ID_LEXICON_ICON,
                   ID_LEXICON_ICON);
    }
    else if (!strcmp(curMod->Type(), "Commentaries"))
    {
      curNode =
        AppendItem(langnode,
                   wxString(curMod->Name(),
                            wxConvUTF8) + wxT(" - ") +
                   wxString(curMod->Description(), wxConvUTF8),
                   ID_COMMENTARY_ICON, ID_COMMENTARY_ICON);
    }
    else if (!strcmp(curMod->Type(), "Daily Devotional"))
    {
      curNode =
        AppendItem(langnode,
                   wxString(curMod->Name(),
                            wxConvUTF8) + wxT(" - ") +
                   wxString(curMod->Description(), wxConvUTF8),
                   ID_DEVOTIONAL_ICON, ID_DEVOTIONAL_ICON);
    }
    else
    {
      curNode =
        AppendItem(langnode,
                   wxString(curMod->Name(),
                            wxConvUTF8) + wxT(" - ") +
                   wxString(curMod->Description(), wxConvUTF8), ID_BOOK_ICON,
                   ID_BOOK_ICON);
    }

    /** END SET ICON **/

    SetItemData(curNode, new BookTreeItemData(curMod));
    SortChildren(childnode);
    SortChildren(langnode);
  }

  SortChildren(rootnode);
}