Index: trunk/src/VBox/Main/Performance.cpp
===================================================================
--- trunk/src/VBox/Main/Performance.cpp	(revision 10678)
+++ trunk/src/VBox/Main/Performance.cpp	(revision 10679)
@@ -22,5 +22,7 @@
  */
 
+#include <VBox/com/array.h>
 #include <VBox/com/ptr.h>
+#include <VBox/com/string.h>
 #include <VBox/err.h>
 #include <iprt/string.h>
@@ -219,4 +221,11 @@
 }
 
+void HostCpuMhz::init(unsigned long period, unsigned long length)
+{
+    mPeriod = period;
+    mLength = length;
+    mMHz->init(mLength);
+}
+
 void HostCpuMhz::collect()
 {
@@ -224,4 +233,13 @@
     mHAL->getHostCpuMHz(&mhz);
     mMHz->put(mhz);
+}
+
+void HostRamUsage::init(unsigned long period, unsigned long length)
+{
+    mPeriod = period;
+    mLength = length;
+    mTotal->init(mLength);
+    mUsed->init(mLength);
+    mAvailable->init(mLength);
 }
 
@@ -236,4 +254,13 @@
 
 
+
+void MachineCpuLoad::init(unsigned long period, unsigned long length)
+{
+    mPeriod = period;
+    mLength = length;
+    mUser->init(mLength);
+    mKernel->init(mLength);
+}
+
 void MachineCpuLoad::collect()
 {
@@ -259,4 +286,11 @@
     mProcessUserPrev   = processUser;
     mProcessKernelPrev = processKernel;
+}
+
+void MachineRamUsage::init(unsigned long period, unsigned long length)
+{
+    mPeriod = period;
+    mLength = length;
+    mUsed->init(mLength);
 }
 
@@ -361,2 +395,29 @@
 }
 
+Filter::Filter(ComSafeArrayIn(const BSTR, metricNames),
+               ComSafeArrayIn(IUnknown *, objects))
+{
+    com::SafeIfaceArray <IUnknown> objectArray(ComSafeArrayInArg(objects));
+    com::SafeArray <BSTR> nameArray(ComSafeArrayInArg(metricNames));
+    for (size_t i = 0; i < objectArray.size(); ++i)
+        processMetricList(std::string(com::Utf8Str(nameArray[i])), objectArray[i]);
+}
+
+void Filter::processMetricList(const std::string &name, const IUnknown *object)
+{
+    std::string::size_type startPos = 0;
+
+    for (std::string::size_type pos = name.find(",");
+         pos != std::string::npos;
+         pos = name.find(",", startPos))
+    {
+        mElements.push_back(std::make_pair(object, name.substr(startPos, pos - startPos)));
+        startPos = pos + 1;
+    }
+    mElements.push_back(std::make_pair(object, name.substr(startPos)));
+}
+
+bool Filter::match(const IUnknown *object, const std::string &name) const
+{
+    return true;
+}
Index: trunk/src/VBox/Main/PerformanceImpl.cpp
===================================================================
--- trunk/src/VBox/Main/PerformanceImpl.cpp	(revision 10678)
+++ trunk/src/VBox/Main/PerformanceImpl.cpp	(revision 10679)
@@ -39,25 +39,25 @@
 static Bstr gMetricNames[] =
 {
-    "CPU/User:avg",
-    "CPU/User:min",
-    "CPU/User:max",
-    "CPU/Kernel:avg",
-    "CPU/Kernel:min",
-    "CPU/Kernel:max",
-    "CPU/Idle:avg",
-    "CPU/Idle:min",
-    "CPU/Idle:max",
+    "CPU/Load/User:avg",
+    "CPU/Load/User:min",
+    "CPU/Load/User:max",
+    "CPU/Load/Kernel:avg",
+    "CPU/Load/Kernel:min",
+    "CPU/Load/Kernel:max",
+    "CPU/Load/Idle:avg",
+    "CPU/Load/Idle:min",
+    "CPU/Load/Idle:max",
     "CPU/MHz:avg",
     "CPU/MHz:min",
     "CPU/MHz:max",
-    "RAM/Total:avg",
-    "RAM/Total:min",
-    "RAM/Total:max",
-    "RAM/Used:avg",
-    "RAM/Used:min",
-    "RAM/Used:max",
-    "RAM/Free:avg",
-    "RAM/Free:min",
-    "RAM/Free:max",
+    "RAM/Usage/Total:avg",
+    "RAM/Usage/Total:min",
+    "RAM/Usage/Total:max",
+    "RAM/Usage/Used:avg",
+    "RAM/Usage/Used:min",
+    "RAM/Usage/Used:max",
+    "RAM/Usage/Free:avg",
+    "RAM/Usage/Free:min",
+    "RAM/Usage/Free:max",
 };
 
@@ -69,5 +69,5 @@
 ////////////////////////////////////////////////////////////////////////////////
 
-PerformanceCollector::PerformanceCollector() : mFactory(0) {}
+PerformanceCollector::PerformanceCollector() {}
 
 PerformanceCollector::~PerformanceCollector() {}
@@ -102,8 +102,8 @@
 
     /* @todo Obviously other platforms must be added as well. */
-    mFactory = new pm::MetricFactoryLinux();
+    m.mFactory = new pm::MetricFactoryLinux();
     /* Start resource usage sampler */
 
-    int vrc = RTTimerCreate (&mSampler, VBOX_USAGE_SAMPLER_MIN_INTERVAL,
+    int vrc = RTTimerCreate (&m.mSampler, VBOX_USAGE_SAMPLER_MIN_INTERVAL,
                              &PerformanceCollector::staticSamplerCallback, this);
     AssertMsgRC (vrc, ("Failed to create resource usage "
@@ -139,11 +139,11 @@
 
     /* Destroy resource usage sampler */
-    int vrc = RTTimerDestroy (mSampler);
+    int vrc = RTTimerDestroy (m.mSampler);
     AssertMsgRC (vrc, ("Failed to destroy resource usage "
                        "sampling timer (%Rra)\n", vrc));
-    mSampler = NULL;
-
-    delete mFactory;
-    mFactory = NULL;
+    m.mSampler = NULL;
+
+    delete m.mFactory;
+    m.mFactory = NULL;
 
     LogFlowThisFuncLeave();
@@ -194,13 +194,12 @@
                                                  ULONG aPeriod, ULONG aCount)
 {
-#if 0
     pm::Filter filter(ComSafeArrayInArg(metricNames), ComSafeArrayInArg(objects));
 
-    std::list<pm::Metric*>::iterator it;
-    for (it = mMetrics.begin(); it != mMetrics.end(); ++it)
-        if (filter.match(*it))
+    BaseMetricList::iterator it;
+    for (it = m.mBaseMetrics.begin(); it != m.mBaseMetrics.end(); ++it)
+        if (filter.match((*it)->getObject(), (*it)->getName()))
             (*it)->init(aPeriod, aCount);
-#endif
-    return E_NOTIMPL;
+
+    return S_OK;
 }
 
@@ -231,8 +230,8 @@
 
     int i;
-    std::list<pm::Metric*>::const_iterator it;
+    MetricList::const_iterator it;
     /* Let's compute the size of the resulting flat array */
     size_t flatSize = 0, numberOfMetrics = 0;
-    for (it = mMetrics.begin(); it != mMetrics.end(); ++it)
+    for (it = m.mMetrics.begin(); it != m.mMetrics.end(); ++it)
     {
         /* @todo Filtering goes here! */
@@ -246,5 +245,5 @@
     com::SafeArray<ULONG> retLengths(numberOfMetrics);
     com::SafeArray<LONG> retData(flatSize);
-    for (it = mMetrics.begin(), i = 0; it != mMetrics.end(); ++it)
+    for (it = m.mMetrics.begin(), i = 0; it != m.mMetrics.end(); ++it)
     {
         /* @todo Filtering goes here! */
@@ -274,15 +273,15 @@
 void PerformanceCollector::registerBaseMetric (pm::BaseMetric *baseMetric)
 {
-    mBaseMetrics.push_back (baseMetric);
+    m.mBaseMetrics.push_back (baseMetric);
 }
 
 void PerformanceCollector::registerMetric (pm::Metric *metric)
 {
-    mMetrics.push_back (metric);
+    m.mMetrics.push_back (metric);
 }
 
 void PerformanceCollector::unregisterBaseMetricsFor (const ComPtr <IUnknown> &aObject)
 {
-    std::remove_if (mBaseMetrics.begin(), mBaseMetrics.end(),
+    std::remove_if (m.mBaseMetrics.begin(), m.mBaseMetrics.end(),
                     std::bind2nd (std::mem_fun (&pm::BaseMetric::associatedWith),
                                   aObject));
@@ -291,5 +290,5 @@
 void PerformanceCollector::unregisterMetricsFor (const ComPtr <IUnknown> &aObject)
 {
-    std::remove_if (mMetrics.begin(), mMetrics.end(),
+    std::remove_if (m.mMetrics.begin(), m.mMetrics.end(),
                     std::bind2nd (std::mem_fun (&pm::Metric::associatedWith),
                                   aObject));
@@ -311,68 +310,4 @@
 }
 
-#if 0
-PerformanceData::PerformanceData()
-{
-}
-
-PerformanceData::~PerformanceData()
-{
-}
-
-HRESULT PerformanceData::FinalConstruct()
-{
-    LogFlowThisFunc (("\n"));
-
-    return S_OK;
-}
-
-void PerformanceData::FinalRelease()
-{
-    LogFlowThisFunc (("\n"));
-
-    uninit ();
-}
-
-HRESULT PerformanceData::init (const char *aMetricName, IUnknown *anObject,
-                               unsigned long *data, unsigned long aLength)
-{
-    mMetricName = aMetricName;
-    mObject = anObject;
-    mData = data;
-    mLength = aLength;
-    return S_OK;
-}
-
-void PerformanceData::uninit()
-{
-    RTMemFree(mData);
-    mData = 0;
-    mLength = 0;
-}
-
-STDMETHODIMP PerformanceData::COMGETTER(MetricName) (BSTR *aMetricName)
-{
-    Bstr tmp(mMetricName);
-    tmp.detachTo(aMetricName);
-    return S_OK;
-}
-
-STDMETHODIMP PerformanceData::COMGETTER(Object) (IUnknown **anObject)
-{
-    *anObject = mObject;
-    return S_OK;
-}
-
-STDMETHODIMP PerformanceData::COMGETTER(Values) (ComSafeArrayOut (LONG, values))
-{
-    SafeArray <LONG> ret (mLength);
-    for (size_t i = 0; i < mLength; ++ i)
-        ret[i] = mData[i];
-
-    ret.detachTo(ComSafeArrayOutArg(values));
-    return S_OK;
-}
-#endif
-
 ////////////////////////////////////////////////////////////////////////////////
 // PerformanceMetric class
Index: trunk/src/VBox/Main/include/Performance.h
===================================================================
--- trunk/src/VBox/Main/include/Performance.h	(revision 10678)
+++ trunk/src/VBox/Main/include/Performance.h	(revision 10679)
@@ -25,4 +25,5 @@
 #include <iprt/types.h>
 #include <VBox/com/defs.h>
+#include <list>
 #include <string>
 
@@ -93,6 +94,8 @@
     {
     public:
-        BaseMetric(CollectorHAL *hal, IUnknown *object) : mLength(0), mHAL(hal), mObject(object) {};
-
+        BaseMetric(CollectorHAL *hal, const char *name, IUnknown *object)
+            : mHAL(hal), mLength(0), mName(name), mObject(object) {};
+
+        virtual void init(unsigned long period, unsigned long length) = 0;
         virtual void collect() = 0;
         virtual const char *getUnit() = 0;
@@ -102,11 +105,13 @@
         unsigned long getPeriod() { return mPeriod; };
         unsigned long getLength() { return mLength; };
+        const char *getName() { return mName; };
         IUnknown *getObject() { return mObject; };
         bool associatedWith(IUnknown *object) { return mObject == object; };
 
     protected:
+        CollectorHAL *mHAL;
         unsigned long mPeriod;
         unsigned long mLength;
-        CollectorHAL *mHAL;
+        const char   *mName;
         IUnknown     *mObject;
     };
@@ -116,5 +121,5 @@
     public:
         HostCpuLoad(CollectorHAL *hal, IUnknown *object, SubMetric *user, SubMetric *kernel, SubMetric *idle)
-        : BaseMetric(hal, object), mUser(user), mKernel(kernel), mIdle(idle) {};
+        : BaseMetric(hal, "CPU/Load", object), mUser(user), mKernel(kernel), mIdle(idle) {};
         void init(unsigned long period, unsigned long length);
 
@@ -135,5 +140,4 @@
         HostCpuLoadRaw(CollectorHAL *hal, IUnknown *object, SubMetric *user, SubMetric *kernel, SubMetric *idle)
         : HostCpuLoad(hal, object, user, kernel, idle), mUserPrev(0), mKernelPrev(0), mIdlePrev(0) {};
-        void init(unsigned long period, unsigned long length);
 
         void collect();
@@ -148,6 +152,7 @@
     public:
         HostCpuMhz(CollectorHAL *hal, IUnknown *object, SubMetric *mhz)
-        : BaseMetric(hal, object), mMHz(mhz) {};
-
+        : BaseMetric(hal, "CPU/MHz", object), mMHz(mhz) {};
+
+        void init(unsigned long period, unsigned long length);
         void collect();
         const char *getUnit() { return "MHz"; };
@@ -162,6 +167,7 @@
     public:
         HostRamUsage(CollectorHAL *hal, IUnknown *object, SubMetric *total, SubMetric *used, SubMetric *available)
-        : BaseMetric(hal, object), mTotal(total), mUsed(used), mAvailable(available) {};
-
+        : BaseMetric(hal, "RAM/Usage", object), mTotal(total), mUsed(used), mAvailable(available) {};
+
+        void init(unsigned long period, unsigned long length);
         void collect();
         const char *getUnit() { return "kB"; };
@@ -178,6 +184,7 @@
     public:
         MachineCpuLoad(CollectorHAL *hal, IUnknown *object, RTPROCESS process, SubMetric *user, SubMetric *kernel)
-        : BaseMetric(hal, object), mProcess(process), mUser(user), mKernel(kernel) {};
-
+        : BaseMetric(hal, "CPU/Load", object), mProcess(process), mUser(user), mKernel(kernel) {};
+
+        void init(unsigned long period, unsigned long length);
         void collect();
         const char *getUnit() { return "%"; };
@@ -207,6 +214,7 @@
     public:
         MachineRamUsage(CollectorHAL *hal, IUnknown *object, RTPROCESS process, SubMetric *used)
-        : BaseMetric(hal, object), mProcess(process), mUsed(used) {};
-
+        : BaseMetric(hal, "RAM/Usage", object), mProcess(process), mUsed(used) {};
+
+        void init(unsigned long period, unsigned long length);
         void collect();
         const char *getUnit() { return "kB"; };
@@ -307,4 +315,17 @@
         virtual BaseMetric   *createMachineCpuLoad(IUnknown *object, RTPROCESS process, SubMetric *user, SubMetric *kernel);
     };
+
+    class Filter
+    {
+    public:
+        Filter(ComSafeArrayIn(const BSTR, metricNames),
+               ComSafeArrayIn(IUnknown *, objects));
+        bool match(const IUnknown *object, const std::string &name) const;
+    private:
+        typedef std::pair<const IUnknown*, const std::string> FilterElement;
+        std::list<FilterElement> mElements;
+
+        void processMetricList(const std::string &name, const IUnknown *object);
+    };
 }
 
Index: trunk/src/VBox/Main/include/PerformanceImpl.h
===================================================================
--- trunk/src/VBox/Main/include/PerformanceImpl.h	(revision 10678)
+++ trunk/src/VBox/Main/include/PerformanceImpl.h	(revision 10679)
@@ -35,4 +35,5 @@
 
 #include <list>
+#include <set>
 
 #include "Performance.h"
@@ -229,5 +230,5 @@
     // (ensure there is a caller and a read lock before calling them!)
     //
-    pm::MetricFactory *getMetricFactory() { return mFactory; };
+    pm::MetricFactory *getMetricFactory() { return m.mFactory; };
 
     // for VirtualBoxSupportErrorInfoImpl
@@ -239,8 +240,15 @@
     void samplerCallback();
 
-    std::list<pm::BaseMetric*> mBaseMetrics;
-    std::list<pm::Metric*>     mMetrics;
-    PRTTIMER                   mSampler;
-    pm::MetricFactory         *mFactory;
+    typedef std::list<pm::Metric*> MetricList;
+    typedef std::list<pm::BaseMetric*> BaseMetricList;
+
+    struct Data {
+        Data() : mFactory(0) {};
+
+        BaseMetricList     mBaseMetrics;
+        MetricList         mMetrics;
+        PRTTIMER           mSampler;
+        pm::MetricFactory *mFactory;
+    } m;
 };
 
Index: trunk/src/VBox/Main/testcase/tstAPI.cpp
===================================================================
--- trunk/src/VBox/Main/testcase/tstAPI.cpp	(revision 10678)
+++ trunk/src/VBox/Main/testcase/tstAPI.cpp	(revision 10679)
@@ -921,5 +921,5 @@
 #if 1
     do {
-        Bstr metricNames[] = { L"CPU/User:avg,CPU/System:avg,CPU/Idle:avg" };
+        Bstr metricNames[] = { L"CPU/Load/User:avg,CPU/Load/System:avg,CPU/Load/Idle:avg" };
         com::SafeArray<BSTR> metrics (1);
         metricNames[0].cloneTo (&metrics [0]);
@@ -954,6 +954,7 @@
             for (unsigned j = 0; j < retLengths[i]; j++)
             {
-                printf(" %d\n", retData[retIndices[i] + j]);
+                printf(" %d", retData[retIndices[i] + j]);
             }
+            printf("\n");
         }
     } while (0);
