myserver-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[myserver-commit] [2942] fixed segfault problem and pluginInfo tests


From: Daniele Perrone
Subject: [myserver-commit] [2942] fixed segfault problem and pluginInfo tests
Date: Fri, 07 Nov 2008 16:42:46 +0000

Revision: 2942
          http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=2942
Author:   dperrone
Date:     2008-11-07 16:42:46 +0000 (Fri, 07 Nov 2008)

Log Message:
-----------
fixed segfault problem and pluginInfo tests

Modified Paths:
--------------
    trunk/myserver/include/plugin/plugin_info.h
    trunk/myserver/src/plugin/plugin_info.cpp
    trunk/myserver/tests/test_plugin_info.cpp

Modified: trunk/myserver/include/plugin/plugin_info.h
===================================================================
--- trunk/myserver/include/plugin/plugin_info.h 2008-11-07 12:29:00 UTC (rev 
2941)
+++ trunk/myserver/include/plugin/plugin_info.h 2008-11-07 16:42:46 UTC (rev 
2942)
@@ -37,7 +37,6 @@
 public:
 
     PluginInfo(string& name, bool enabled = 1, bool global = 0);
-       PluginInfo(string& name, bool enabled, bool global, int version, int 
msMinVersion, int msMaxVersion);
        
        ~PluginInfo();
        
@@ -63,13 +62,7 @@
        HashMap<string, pair<int,int>* >::Iterator begin(){return 
dependences.begin();}
        HashMap<string, pair<int,int>* > ::Iterator end(){return 
dependences.end();}
        
-       void attachPlugin(Plugin* plugin);
        
-       Plugin* getPlugin();
-       
-       void detachPlugin();
-       
-       
        static int convertVersion(string* s);
        
        
@@ -84,7 +77,6 @@
     int msMinVersion;
     int msMaxVersion;
     HashMap<string, pair<int,int>* > dependences;
-    Plugin* plugin;
     static Regex* regex;
 };
 

Modified: trunk/myserver/src/plugin/plugin_info.cpp
===================================================================
--- trunk/myserver/src/plugin/plugin_info.cpp   2008-11-07 12:29:00 UTC (rev 
2941)
+++ trunk/myserver/src/plugin/plugin_info.cpp   2008-11-07 16:42:46 UTC (rev 
2942)
@@ -20,6 +20,9 @@
 
 using namespace std;
 
+Regex* PluginInfo::regex = new 
Regex("^[1-2]?[1-9]?[0-9](\\.[1-2]?[0-9]?[0-9](\\.[1-2]?[0-9]?[0-9](\\.[1-2]?[0-9]?[0-9])?)?)?$",REG_EXTENDED
 | REG_NOSUB);
+
+
 /*!
  *Construct a plugin info object.
  *\param name plugin name.
@@ -28,36 +31,23 @@
  */
 PluginInfo::PluginInfo(string& name, bool enabled, bool global)
 {
-  PluginInfo(name,enabled,global,0,0,0);
-}
-
-/*!
- *Construct a plugin info object.
- *\param name plugin name.
- *\param enabled is true if the plugin has to be enabled. 
- *\param global is true if the plugin's symbols have to be loaded globally.
- *\param version the version of the plugin, in the format: a.b.c.d where a = 
version >> 24, b = (version >> 16) & 255, c = (version >> 8) & 255, d = version 
& 255.
- *\param msMinVersion is the minimum MyServer version plugin is compatible. 
- *\param msMaxVersion is the maximum MyServer version plugin is compatible. 
- */
-PluginInfo::PluginInfo(string& name, bool enabled, bool global, int version, 
int msMinVersion, int msMaxVersion)
-{
   this->name = name;   
   this->enabled = enabled;
   this->global = global;
-  this->version = version;
-  this->msMinVersion = msMinVersion;
-  this->msMaxVersion = msMaxVersion;
-  this->plugin = NULL;
+  this->version = 0;
+  this->msMinVersion = 0;
+  this->msMaxVersion = 0;
 }
 
 
+
+
 /*!
  *Destroy the object.
 */     
 PluginInfo::~PluginInfo()
 {
-       detachPlugin();
+
 }
 
 /*!
@@ -144,38 +134,6 @@
 }
 
 /*!
- * Attaches the corrispondent Plugin object.
-*/
-void PluginInfo::attachPlugin(Plugin* plugin)
-{
-       this->plugin = plugin;
-}
-
-
-/*!
- * Returns the attached plugin object.
-*/
-Plugin* PluginInfo::getPlugin()
-{
-  return this->plugin;
-}
-       
-/*!
- * Detaches the Plugin object.
-*/
-void PluginInfo::detachPlugin()
-{
-  if (!this->plugin)
-  {
-       delete this->plugin;
-  }
-}
-
-
-
-Regex* PluginInfo::regex = new 
Regex("^[1-2]?[1-9]?[0-9](\\.[1-2]?[0-9]?[0-9](\\.[1-2]?[0-9]?[0-9](\\.[1-2]?[0-9]?[0-9])?)?)?$",REG_EXTENDED
 | REG_NOSUB);
-
-/*!
  * Converts a string in the format "a.b.c.d" in an int in the format abcd 
where each number takes 8 bit.
 */
 int PluginInfo::convertVersion(string* s)

Modified: trunk/myserver/tests/test_plugin_info.cpp
===================================================================
--- trunk/myserver/tests/test_plugin_info.cpp   2008-11-07 12:29:00 UTC (rev 
2941)
+++ trunk/myserver/tests/test_plugin_info.cpp   2008-11-07 16:42:46 UTC (rev 
2942)
@@ -40,9 +40,6 @@
   CPPUNIT_TEST( testGetMyServerMaxVersion );
   CPPUNIT_TEST( testGetName );
   CPPUNIT_TEST( testDependencies );
-  CPPUNIT_TEST( testGetNullPlugin );
-  CPPUNIT_TEST( testAddAndGetPlugin );
-  CPPUNIT_TEST( testDetachPlugin );
   CPPUNIT_TEST( testVersionConversionStringInt );
   CPPUNIT_TEST_SUITE_END();
 private:
@@ -52,7 +49,7 @@
   void setUp()
   {
        string name("test");
-       pluginfo = new PluginInfo(name,false,false,0,0,0);
+       pluginfo = new PluginInfo(name,false,false);
   }
 
   void tearDown()
@@ -69,7 +66,7 @@
   {
        delete(pluginfo);
        string name("test");
-       pluginfo = new PluginInfo(name,true,false,0,0,0);
+       pluginfo = new PluginInfo(name,true,false);
        CPPUNIT_ASSERT(pluginfo->isEnabled());
   }
 
@@ -82,7 +79,7 @@
   {
        delete(pluginfo);
        string name("test");
-       pluginfo = new PluginInfo(name,false,true,0,0,0);
+       pluginfo = new PluginInfo(name,false,true);
        CPPUNIT_ASSERT(pluginfo->isGlobal());
   }
   
@@ -115,25 +112,8 @@
        CPPUNIT_ASSERT_EQUAL( pluginfo->begin().getKey().compare("test-dep"),0);
   }
   
-  void testGetNullPlugin()
-  {
-       CPPUNIT_ASSERT( pluginfo->getPlugin()==NULL);
-  }
+
   
-  void testAddAndGetPlugin()
-  {
-       pluginfo->attachPlugin(new Plugin());
-       CPPUNIT_ASSERT( pluginfo->getPlugin()!=NULL);
-  }
-  
-  void testDetachPlugin()
-  {
-       pluginfo->attachPlugin(new Plugin());
-       CPPUNIT_ASSERT( pluginfo->getPlugin()!=NULL);
-       pluginfo->detachPlugin();
-       CPPUNIT_ASSERT( pluginfo->getPlugin()==NULL);
-  }
-  
   void testVersionConversionStringInt()
   {
        int v = PluginInfo::convertVersion(new string("1"));






reply via email to

[Prev in Thread] Current Thread [Next in Thread]