Changeset 4879 for branches/erijo-dev

Show
Ignore:
Timestamp:
04/01/07 04:09:14 (20 months ago)
Author:
erijo
Message:

Cache plugin information on the heap and pass them around as smart pointers.

Location:
branches/erijo-dev/licq
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • branches/erijo-dev/licq/licq/interface/plugininformation.h

    r4868 r4879  
    2121#define LICQ_TPLUGININFORMATION_H 
    2222 
     23#include <boost/shared_ptr.hpp> 
    2324#include <string> 
    2425#include <vector> 
     
    2627namespace Licq 
    2728{ 
     29 
     30class TPluginInformation; 
     31typedef boost::shared_ptr<const TPluginInformation> TPluginInformationPtr; 
    2832 
    2933enum TPluginType 
  • branches/erijo-dev/licq/src/plugin/pluginrepository.cpp

    r4873 r4879  
    6565      entry->Factory = *factory; 
    6666      entry->Index = index; 
    67       entry->Information = (*factory)->getPluginInformation(index); 
     67      entry->Information 
     68        .reset(new TPluginInformation((*factory)->getPluginInformation(index))); 
     69 
     70      if (entry->Information->Name.empty()) 
     71      { 
     72        Log->warning("Skipping plugin with no name"); 
     73        delete entry; 
     74        continue; 
     75      } 
    6876 
    6977      // Check for duplicate plugins 
    70       TPluginCache::iterator cache = PluginCache.find(entry->Information.Name); 
     78      TPluginCache::iterator cache = PluginCache.find(entry->Information->Name); 
    7179      if (cache != PluginCache.end()) 
    7280      { 
    7381        // Keep the one with the highest IntVersion, or if equal, the first loaded. 
    74         if (entry->Information.IntVersion <= cache->second->Information.IntVersion) 
     82        if (entry->Information->IntVersion  
     83            <= cache->second->Information->IntVersion) 
    7584        { 
    7685          delete entry; 
     
    92101 
    93102      // Cache plugin 
    94       PluginCache[entry->Information.Name] = entry; 
     103      PluginCache[entry->Information->Name] = entry; 
    95104    } 
    96105  } 
     
    103112 
    104113void Licq::TPluginRepository:: 
    105 getAvailablePlugins(std::list<TPluginInformation>* pluginInformation) 
     114getAvailablePlugins(std::list<TPluginInformationPtr>* pluginInformation) 
    106115{ 
    107116  for (TPluginCache::const_iterator cache = PluginCache.begin(); 
  • branches/erijo-dev/licq/src/plugin/pluginrepository.h

    r4869 r4879  
    5353    boost::weak_ptr<IPluginFactory> Factory; 
    5454    unsigned int Index; 
    55     TPluginInformation Information; 
     55    TPluginInformationPtr Information; 
    5656  }; 
    5757 
     
    7070  void unloadUnusedPlugins(); 
    7171 
    72   void getAvailablePlugins(std::list<TPluginInformation>* pluginInformation); 
     72  void getAvailablePlugins(std::list<TPluginInformationPtr>* pluginInformation); 
    7373 
    7474  IPlugin* createPlugin(const std::string& name);