Index: trunk/include/VBox/com/ptr.h
===================================================================
--- trunk/include/VBox/com/ptr.h	(revision 26753)
+++ trunk/include/VBox/com/ptr.h	(revision 27607)
@@ -73,34 +73,4 @@
     void LogRef(const char *pcszFormat, ...);
 }
-
-/**
- *  Strong referencing operators. Used as a second argument to ComPtr<>/ComObjPtr<>.
- */
-template <class C>
-class ComStrongRef
-{
-protected:
-
-    static void addref(C *p)
-    {
-        p->AddRef();
-    }
-    static void release(C *p)
-    {
-        p->Release();
-    }
-};
-
-/**
- *  Weak referencing operators. Used as a second argument to ComPtr<>/ComObjPtr<>.
- */
-template <class C>
-class ComWeakRef
-{
-protected:
-
-    static void addref(C * /* p */) {}
-    static void release(C * /* p */) {}
-};
 
 /**
@@ -169,6 +139,6 @@
  *  Base template for smart COM pointers. Not intended to be used directly.
  */
-template <class C, template <class> class RefOps = ComStrongRef>
-class ComPtrBase : protected RefOps <C>
+template <class C>
+class ComPtrBase
 {
 public:
@@ -190,19 +160,34 @@
 protected:
 
-    ComPtrBase () : p (NULL) {}
-    ComPtrBase (const ComPtrBase &that) : p (that.p) { addref(); }
-    ComPtrBase (C *that_p) : p (that_p) { addref(); }
-
-    ~ComPtrBase() { release(); }
-
-    ComPtrBase &operator= (const ComPtrBase &that)
-    {
-        safe_assign (that.p);
-        return *this;
-    }
-
-    ComPtrBase &operator= (C *that_p)
-    {
-        safe_assign (that_p);
+    ComPtrBase()
+        : p(NULL)
+    {}
+
+    ComPtrBase(const ComPtrBase &that)
+        : p(that.p)
+    {
+        addref();
+    }
+
+    ComPtrBase(C *that_p)
+        : p(that_p)
+    {
+        addref();
+    }
+
+    ~ComPtrBase()
+    {
+        release();
+    }
+
+    ComPtrBase &operator=(const ComPtrBase &that)
+    {
+        safe_assign(that.p);
+        return *this;
+    }
+
+    ComPtrBase &operator=(C *that_p)
+    {
+        safe_assign(that_p);
         return *this;
     }
@@ -221,23 +206,23 @@
     }
 
-    bool operator! () const { return isNull(); }
-
-    bool operator< (C* that_p) const { return p < that_p; }
-    bool operator== (C* that_p) const { return p == that_p; }
+    bool operator!() const { return isNull(); }
+
+    bool operator<(C* that_p) const { return p < that_p; }
+    bool operator==(C* that_p) const { return p == that_p; }
 
     template <class I>
-    bool equalsTo (I *aThat) const
-    {
-        return ComPtrEquals (p, aThat);
+    bool equalsTo(I *aThat) const
+    {
+        return ComPtrEquals(p, aThat);
     }
 
     template <class OC>
-    bool equalsTo (const ComPtrBase <OC> &oc) const
-    {
-        return equalsTo ((OC *) oc);
+    bool equalsTo(const ComPtrBase <OC> &oc) const
+    {
+        return equalsTo((OC*)oc);
     }
 
     /** Intended to pass instances as in parameters to interface methods */
-    operator C* () const { return p; }
+    operator C*() const { return p; }
 
     /**
@@ -245,12 +230,12 @@
      *  pointer).
      */
-    NoAddRefRelease <C> *operator-> () const
-    {
-        AssertMsg (p, ("Managed pointer must not be null\n"));
-        return (NoAddRefRelease <C> *) p;
+    NoAddRefRelease<C>* operator->() const
+    {
+        AssertMsg(p, ("Managed pointer must not be null\n"));
+        return (NoAddRefRelease<C>*)p;
     }
 
     template <class I>
-    HRESULT queryInterfaceTo (I **pp) const
+    HRESULT queryInterfaceTo(I **pp) const
     {
         if (pp)
@@ -258,5 +243,5 @@
             if (p)
             {
-                return p->QueryInterface (COM_IIDOF (I), (void **) pp);
+                return p->QueryInterface(COM_IIDOF(I), (void**)pp);
             }
             else
@@ -282,5 +267,5 @@
     {
         if (p)
-            RefOps <C>::addref (p);
+            p->AddRef();
     }
 
@@ -288,5 +273,5 @@
     {
         if (p)
-            RefOps <C>::release (p);
+            p->Release();
     }
 
@@ -295,5 +280,5 @@
         /* be aware of self-assignment */
         if (that_p)
-            RefOps <C>::addref (that_p);
+            that_p->AddRef();
         release();
         p = that_p;
@@ -309,14 +294,14 @@
  *  @param I    COM interface class
  */
-template <class I, template <class> class RefOps = ComStrongRef>
-class ComPtr : public ComPtrBase <I, RefOps>
-{
-    typedef ComPtrBase <I, RefOps> Base;
+template <class I>
+class ComPtr : public ComPtrBase<I>
+{
+    typedef ComPtrBase<I> Base;
 
 public:
 
-    ComPtr () : Base() {}
-    ComPtr (const ComPtr &that) : Base (that) {}
-    ComPtr &operator= (const ComPtr &that)
+    ComPtr() : Base() {}
+    ComPtr(const ComPtr &that) : Base(that) {}
+    ComPtr& operator=(const ComPtr &that)
     {
         Base::operator= (that);
@@ -325,17 +310,17 @@
 
     template <class OI>
-    ComPtr (OI *that_p) : Base () { operator= (that_p); }
+    ComPtr(OI *that_p) : Base() { operator=(that_p); }
 
     /* specialization for I */
-    ComPtr (I *that_p) : Base (that_p) {}
+    ComPtr(I *that_p) : Base(that_p) {}
 
     template <class OC>
-    ComPtr (const ComPtr <OC, RefOps> &oc) : Base () { operator= ((OC *) oc); }
+    ComPtr(const ComPtr<OC> &oc) : Base() { operator=((OC*)oc); }
 
     template <class OI>
-    ComPtr &operator= (OI *that_p)
+    ComPtr &operator=(OI *that_p)
     {
         if (that_p)
-            that_p->QueryInterface (COM_IIDOF (I), (void **) Base::asOutParam());
+            that_p->QueryInterface(COM_IIDOF(I), (void**)Base::asOutParam());
         else
             Base::setNull();
@@ -346,12 +331,12 @@
     ComPtr &operator=(I *that_p)
     {
-        Base::operator= (that_p);
+        Base::operator=(that_p);
         return *this;
     }
 
     template <class OC>
-    ComPtr &operator= (const ComPtr <OC, RefOps> &oc)
-    {
-        return operator= ((OC *) oc);
+    ComPtr &operator=(const ComPtr<OC> &oc)
+    {
+        return operator=((OC*)oc);
     }
 
@@ -365,15 +350,15 @@
         I *obj = NULL;
 #if !defined (VBOX_WITH_XPCOM)
-        rc = CoCreateInstance (clsid, NULL, CLSCTX_INPROC_SERVER, _ATL_IIDOF (I),
-                               (void **) &obj);
+        rc = CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER, _ATL_IIDOF(I),
+                              (void**)&obj);
 #else /* !defined (VBOX_WITH_XPCOM) */
-        nsCOMPtr <nsIComponentManager> manager;
-        rc = NS_GetComponentManager (getter_AddRefs (manager));
-        if (SUCCEEDED (rc))
-            rc = manager->CreateInstance (clsid, nsnull, NS_GET_IID (I),
-                                          (void **) &obj);
+        nsCOMPtr<nsIComponentManager> manager;
+        rc = NS_GetComponentManager(getter_AddRefs(manager));
+        if (SUCCEEDED(rc))
+            rc = manager->CreateInstance(clsid, nsnull, NS_GET_IID(I),
+                                         (void **) &obj);
 #endif /* !defined (VBOX_WITH_XPCOM) */
         *this = obj;
-        if (SUCCEEDED (rc))
+        if (SUCCEEDED(rc))
             obj->Release();
         return rc;
@@ -389,17 +374,17 @@
      *  method is fully equivalent to #createInprocObject() for now.
      */
-    HRESULT createLocalObject (const CLSID &clsid)
+    HRESULT createLocalObject(const CLSID &clsid)
     {
 #if !defined (VBOX_WITH_XPCOM)
         HRESULT rc;
         I *obj = NULL;
-        rc = CoCreateInstance (clsid, NULL, CLSCTX_LOCAL_SERVER, _ATL_IIDOF (I),
-                               (void **) &obj);
+        rc = CoCreateInstance(clsid, NULL, CLSCTX_LOCAL_SERVER, _ATL_IIDOF(I),
+                              (void**)&obj);
         *this = obj;
-        if (SUCCEEDED (rc))
+        if (SUCCEEDED(rc))
             obj->Release();
         return rc;
 #else /* !defined (VBOX_WITH_XPCOM) */
-        return createInprocObject (clsid);
+        return createInprocObject(clsid);
 #endif /* !defined (VBOX_WITH_XPCOM) */
     }
@@ -412,24 +397,23 @@
      *  @param serverName   Name of the server to create an object within.
      */
-    HRESULT createObjectOnServer (const CLSID &clsid, const char *serverName)
+    HRESULT createObjectOnServer(const CLSID &clsid, const char *serverName)
     {
         HRESULT rc;
         I *obj = NULL;
-        nsCOMPtr <ipcIService> ipcServ = do_GetService (IPC_SERVICE_CONTRACTID, &rc);
-        if (SUCCEEDED (rc))
+        nsCOMPtr<ipcIService> ipcServ = do_GetService(IPC_SERVICE_CONTRACTID, &rc);
+        if (SUCCEEDED(rc))
         {
             PRUint32 serverID = 0;
-            rc = ipcServ->ResolveClientName (serverName, &serverID);
+            rc = ipcServ->ResolveClientName(serverName, &serverID);
             if (SUCCEEDED (rc))
             {
-                nsCOMPtr <ipcIDConnectService> dconServ =
-                    do_GetService (IPC_DCONNECTSERVICE_CONTRACTID, &rc);
-                if (SUCCEEDED (rc))
-                    rc = dconServ->CreateInstance (serverID, clsid, NS_GET_IID (I),
-                                                   (void **) &obj);
+                nsCOMPtr<ipcIDConnectService> dconServ = do_GetService(IPC_DCONNECTSERVICE_CONTRACTID, &rc);
+                if (SUCCEEDED(rc))
+                    rc = dconServ->CreateInstance(serverID, clsid, NS_GET_IID(I),
+                                                  (void**)&obj);
             }
         }
         *this = obj;
-        if (SUCCEEDED (rc))
+        if (SUCCEEDED(rc))
             obj->Release();
         return rc;
@@ -443,30 +427,30 @@
  *  another interface pointer disregarding its type.
  */
-template <template <class> class RefOps>
-class ComPtr <IUnknown, RefOps> : public ComPtrBase <IUnknown, RefOps>
-{
-    typedef ComPtrBase <IUnknown, RefOps> Base;
+template<>
+class ComPtr<IUnknown> : public ComPtrBase<IUnknown>
+{
+    typedef ComPtrBase<IUnknown> Base;
 
 public:
 
-    ComPtr () : Base() {}
-    ComPtr (const ComPtr &that) : Base (that) {}
-    ComPtr &operator= (const ComPtr &that)
-    {
-        Base::operator= (that);
+    ComPtr() : Base() {}
+    ComPtr(const ComPtr &that) : Base (that) {}
+    ComPtr& operator=(const ComPtr &that)
+    {
+        Base::operator=(that);
         return *this;
     }
 
     template <class OI>
-    ComPtr (OI *that_p) : Base () { operator= (that_p); }
+    ComPtr(OI *that_p) : Base() { operator=(that_p); }
 
     template <class OC>
-    ComPtr (const ComPtr <OC, RefOps> &oc) : Base () { operator= ((OC *) oc); }
+    ComPtr(const ComPtr<OC> &oc) : Base() { operator=((OC*)oc); }
 
     template <class OI>
-    ComPtr &operator= (OI *that_p)
+    ComPtr &operator=(OI *that_p)
     {
         if (that_p)
-            that_p->QueryInterface (COM_IIDOF (IUnknown), (void **) Base::asOutParam());
+            that_p->QueryInterface(COM_IIDOF(IUnknown), (void**)Base::asOutParam());
         else
             Base::setNull();
@@ -475,7 +459,7 @@
 
     template <class OC>
-    ComPtr &operator= (const ComPtr <OC, RefOps> &oc)
-    {
-        return operator= ((OC *) oc);
+    ComPtr &operator=(const ComPtr<OC> &oc)
+    {
+        return operator=((OC*)oc);
     }
 };
@@ -489,24 +473,24 @@
  *  @param C    class that implements some COM interface
  */
-template <class C, template <class> class RefOps = ComStrongRef>
-class ComObjPtr : public ComPtrBase <C, RefOps>
-{
-    typedef ComPtrBase <C, RefOps> Base;
+template <class C>
+class ComObjPtr : public ComPtrBase<C>
+{
+    typedef ComPtrBase<C> Base;
 
 public:
 
-    ComObjPtr () : Base() {}
-    ComObjPtr (const ComObjPtr &that) : Base (that) {}
-    ComObjPtr (C *that_p) : Base (that_p) {}
-
-    ComObjPtr &operator= (const ComObjPtr &that)
-    {
-        Base::operator= (that);
-        return *this;
-    }
-
-    ComObjPtr &operator= (C *that_p)
-    {
-        Base::operator= (that_p);
+    ComObjPtr() : Base() {}
+    ComObjPtr(const ComObjPtr &that) : Base(that) {}
+    ComObjPtr(C *that_p) : Base(that_p) {}
+
+    ComObjPtr& operator=(const ComObjPtr &that)
+    {
+        Base::operator=(that);
+        return *this;
+    }
+
+    ComObjPtr& operator=(C *that_p)
+    {
+        Base::operator=(that_p);
         return *this;
     }
@@ -530,5 +514,5 @@
 #if !defined (VBOX_WITH_XPCOM)
 #   ifdef VBOX_COM_OUTOFPROC_MODULE
-        CComObjectNoLock <C> *obj = new CComObjectNoLock <C>();
+        CComObjectNoLock<C> *obj = new CComObjectNoLock<C>();
         if (obj)
         {
@@ -540,9 +524,9 @@
             rc = E_OUTOFMEMORY;
 #   else
-        CComObject <C> *obj = NULL;
-        rc = CComObject <C>::CreateInstance (&obj);
+        CComObject<C> *obj = NULL;
+        rc = CComObject<C>::CreateInstance(&obj);
 #   endif
 #else /* !defined (VBOX_WITH_XPCOM) */
-        CComObject <C> *obj = new CComObject <C>();
+        CComObject<C> *obj = new CComObject<C>();
         if (obj)
             rc = obj->FinalConstruct();
