changeset 20:68b8b32a2070

* Add virtual destructors to PluginBase and Plugin to ensure subclass dtors get called * Fix buglet in host that caused plugin soname to be used as plugin name if no plugin name provided on command line * Add header dependencies to Makefile
author cannam
date Wed, 12 Apr 2006 12:32:18 +0000
parents 08ee18123f5a
children 16eeab18bf72
files Makefile host/simplehost.cpp vamp-sdk/Plugin.h vamp-sdk/PluginBase.h
diffstat 4 files changed, 32 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile	Wed Apr 12 09:57:07 2006 +0000
+++ b/Makefile	Wed Apr 12 12:32:18 2006 +0000
@@ -40,6 +40,16 @@
 
 ### End of user-serviceable parts
 
+API_HEADERS	= \
+		$(APIDIR)/vamp.h
+
+SDK_HEADERS	= \
+		$(SDKDIR)/Plugin.h \
+		$(SDKDIR)/PluginAdapter.h \
+		$(SDKDIR)/PluginBase.h \
+		$(SDKDIR)/PluginHostAdapter.h \
+		$(SDKDIR)/RealTime.h
+
 SDK_OBJECTS	= \
 		$(SDKDIR)/PluginAdapter.o \
 		$(SDKDIR)/PluginHostAdapter.o \
@@ -48,14 +58,21 @@
 SDK_TARGET	= \
 		$(SDKDIR)/libvamp-sdk.a
 
+PLUGIN_HEADERS	= \
+		$(EXAMPLEDIR)/SpectralCentroid.h \
+		$(EXAMPLEDIR)/ZeroCrossing.h
+
 PLUGIN_OBJECTS	= \
+		$(EXAMPLEDIR)/SpectralCentroid.o \
 		$(EXAMPLEDIR)/ZeroCrossing.o \
-		$(EXAMPLEDIR)/SpectralCentroid.o \
 		$(EXAMPLEDIR)/plugins.o
 
 PLUGIN_TARGET	= \
 		$(EXAMPLEDIR)/plugins$(PLUGIN_EXT)
 
+HOST_HEADERS	= \
+		$(HOSTDIR)/system.h
+
 HOST_OBJECTS	= \
 		$(HOSTDIR)/simplehost.o
 
@@ -64,14 +81,14 @@
 
 all:		$(SDK_TARGET) $(PLUGIN_TARGET) $(HOST_TARGET) test
 
-$(SDK_TARGET):	$(SDK_OBJECTS)
-		$(AR) r $@ $^
+$(SDK_TARGET):	$(SDK_OBJECTS) $(API_HEADERS) $(SDK_HEADERS)
+		$(AR) r $@ $(SDK_OBJECTS)
 
-$(PLUGIN_TARGET):	$(PLUGIN_OBJECTS) $(SDK_TARGET)
-		$(CXX) $(LDFLAGS) $(PLUGIN_LDFLAGS) -o $@ $^ $(PLUGIN_LIBS)
+$(PLUGIN_TARGET):	$(PLUGIN_OBJECTS) $(SDK_TARGET) $(PLUGIN_HEADERS)
+		$(CXX) $(LDFLAGS) $(PLUGIN_LDFLAGS) -o $@ $(PLUGIN_OBJECTS) $(PLUGIN_LIBS)
 
-$(HOST_TARGET):	$(HOST_OBJECTS) $(SDK_TARGET)
-		$(CXX) $(LDFLAGS) $(HOST_LDFLAGS) -o $@ $^ $(HOST_LIBS)
+$(HOST_TARGET):	$(HOST_OBJECTS) $(SDK_TARGET) $(HOST_HEADERS)
+		$(CXX) $(LDFLAGS) $(HOST_LDFLAGS) -o $@ $(HOST_OBJECTS) $(HOST_LIBS)
 
 test:		$(HOST_TARGET) $(PLUGIN_TARGET)
 		$(HOST_TARGET) $(PLUGIN_TARGET)
--- a/host/simplehost.cpp	Wed Apr 12 09:57:07 2006 +0000
+++ b/host/simplehost.cpp	Wed Apr 12 12:32:18 2006 +0000
@@ -75,9 +75,10 @@
     string wavname;
     if (argc >= 3) wavname = argv[2];
 
-    if (soname.find(":") >= 0) {
-        plugname = soname.substr(soname.find(":") + 1);
-        soname = soname.substr(0, soname.find(":"));
+    int sep = soname.find(":");
+    if (sep >= 0 && sep < soname.length()) {
+        plugname = soname.substr(sep + 1);
+        soname = soname.substr(0, sep);
     }
 
     void *libraryHandle = DLOPEN(soname, RTLD_LAZY);
--- a/vamp-sdk/Plugin.h	Wed Apr 12 09:57:07 2006 +0000
+++ b/vamp-sdk/Plugin.h	Wed Apr 12 12:32:18 2006 +0000
@@ -114,6 +114,8 @@
 class Plugin : public PluginBase
 {
 public:
+    virtual ~Plugin() { }
+
     /**
      * Initialise a plugin to prepare it for use with the given number
      * of input channels, step size (window increment, in sample
--- a/vamp-sdk/PluginBase.h	Wed Apr 12 09:57:07 2006 +0000
+++ b/vamp-sdk/PluginBase.h	Wed Apr 12 12:32:18 2006 +0000
@@ -56,6 +56,8 @@
 class PluginBase 
 {
 public:
+    virtual ~PluginBase() { }
+
     /**
      * Get the computer-usable name of the plugin.  This should be
      * reasonably short and contain no whitespace or punctuation