[vlmc-devel] commit: EffectsEngine : Code factorisation on disconnections ( Vincent Carrubba )

git at videolan.org git at videolan.org
Tue Apr 20 00:52:42 CEST 2010


vlmc | branch: master | Vincent Carrubba <cyberbouba at gmail.com> | Tue Apr 13 10:14:49 2010 +0200| [c5e223a223e1fe7536802b8886ac4ce9e42bd6f9] | committer: Hugo Beauzée-Luyssen 

EffectsEngine : Code factorisation on disconnections

Signed-off-by: Hugo Beauzée-Luyssen <beauze.h at gmail.com>

> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=c5e223a223e1fe7536802b8886ac4ce9e42bd6f9
---

 src/EffectsEngine/EffectNode.cpp |  200 +++++++++++++++++++-------------------
 src/EffectsEngine/EffectNode.h   |   25 +++--
 2 files changed, 118 insertions(+), 107 deletions(-)

diff --git a/src/EffectsEngine/EffectNode.cpp b/src/EffectsEngine/EffectNode.cpp
index 5dbf49f..a1b4478 100644
--- a/src/EffectsEngine/EffectNode.cpp
+++ b/src/EffectsEngine/EffectNode.cpp
@@ -442,79 +442,6 @@ EffectNode::connectStaticVideoOutputToStaticVideoInput( quint32 outId, quint32 n
 }
 
 //
-// SLOTS DISCONNECTION
-//
-
-bool
-EffectNode::disconnectStaticVideoOutput( quint32 nodeId )
-{
-    QWriteLocker                        wl( &m_rwl );
-    OutSlot<LightVideoFrame>*  out;
-    InSlot<LightVideoFrame>*   in;
-    EffectNode*                father;
-
-    if ( ( out = m_staticVideosOutputs.getObject( nodeId ) ) == NULL )
-        return false;
-
-    in = out->getInSlotPtr();
-    if ( out->disconnect() == false )
-        return false;
-    if ( m_connectedStaticVideosOutputs.delObjectReference( out->getId() ) == false )
-        return false;
-    father = in->getPrivateFather();
-    if ( father == m_father )
-    {
-        if ( father->dereferenceInternalStaticVideoInputAsConnected( in->getId() ) == false )
-            return false;
-    }
-    else if ( father == this )
-    {
-        if ( m_connectedStaticVideosInputs.delObjectReference( in->getId() ) == false )
-            return false;
-    }
-    else
-    {
-        if ( father->dereferenceStaticVideoInputAsConnected( in->getId() ) == false )
-            return false;
-    }
-    return true;
-}
-
-bool
-EffectNode::disconnectStaticVideoOutput( const QString & nodeName )
-{
-    QWriteLocker                        wl( &m_rwl );
-    OutSlot<LightVideoFrame>*  out;
-    InSlot<LightVideoFrame>*   in;
-    EffectNode*                father;
-
-    if ( ( out = m_staticVideosOutputs.getObject( nodeName ) ) == NULL )
-        return false;
-    in = out->getInSlotPtr();
-    if ( out->disconnect() == false )
-        return false;
-    if ( m_connectedStaticVideosOutputs.delObjectReference( out->getId() ) == false )
-        return false;
-    father = in->getPrivateFather();
-    if ( father == m_father )
-    {
-        if ( father->dereferenceInternalStaticVideoInputAsConnected( in->getId() ) == false )
-            return false;
-    }
-    else if ( father == this )
-    {
-        if ( m_connectedStaticVideosInputs.delObjectReference( in->getId() ) == false)
-            return false;
-    }
-    else
-    {
-        if ( father->dereferenceStaticVideoInputAsConnected( in->getId() ) == false )
-            return false;
-    }
-    return true;
-}
-
-//
 // CHILD TO PARENT / PARENT TO CHILD CONNECTION
 //
 
@@ -684,49 +611,124 @@ EffectNode::connectChildStaticVideoInputToParentStaticVideoOutput( quint32 child
 }
 
 //
-// INTERNALS SLOTS DISCONNECTION
+// PRIMITIVE DISCONNECTION
 //
 
 bool
-EffectNode::disconnectInternalStaticVideoOutput( quint32 nodeId )
+EffectNode::primitiveDisconnection( quint32 nodeId,
+                                    const QString & nodeName,
+                                    bool internal )
 {
-    QWriteLocker                        wl( &m_rwl );
-    OutSlot<LightVideoFrame>*  out;
-    InSlot<LightVideoFrame>*   in;
-    EffectNode*                father;
+    OutSlot<LightVideoFrame>*           out;
+    InSlot<LightVideoFrame>*            in;
+    EffectNode*                         father;
+
 
-    if ( ( out = m_internalsStaticVideosOutputs.getObject( nodeId ) ) == NULL )
+    if ( nodeId == 0 && nodeName.size() != 0 )
+    {
+        if ( ( out = m_staticVideosOutputs.getObject( nodeName ) ) == NULL )
+            return false;
+    }
+    else if ( nodeId != 0 && nodeName.size() == 0 )
+    {
+        if ( ( out = m_staticVideosOutputs.getObject( nodeId ) ) == NULL )
+            return false;
+    }
+    else
         return false;
+
+    if ( internal == true )
+    {
+        if ( m_connectedStaticVideosOutputs.delObjectReference( out->getId() ) == false )
+            return false;
+    }
+    else
+    {
+        if ( m_connectedInternalsStaticVideosOutputs.delObjectReference( out->getId() ) == false )
+            return false;
+    }
+
     in = out->getInSlotPtr();
-    if ( out->disconnect() == false )
-        return false;
-    if ( m_connectedInternalsStaticVideosOutputs.delObjectReference( out->getId() ) == false )
-        return false;
+
     father = in->getPrivateFather();
-    if ( father->dereferenceStaticVideoInputAsConnected( in->getId() ) == false )
+
+    if ( internal == true )
+    {
+        if ( father == this )
+        {
+            if ( m_connectedInternalsStaticVideosInputs.delObjectReference( in->getId() ) == false )
+                return false;
+        }
+        else
+        {
+            if ( father->dereferenceStaticVideoInputAsConnected( in->getId() ) == false )
+                return false;
+        }
+    }
+    else
+    {
+        if ( father == m_father )
+        {
+            if ( father->dereferenceInternalStaticVideoInputAsConnected( in->getId() ) == false )
+                return false;
+        }
+        else if ( father == this )
+        {
+            if ( m_connectedStaticVideosInputs.delObjectReference( in->getId() ) == false )
+                return false;
+        }
+        else
+        {
+            if ( father->dereferenceStaticVideoInputAsConnected( in->getId() ) == false )
+                return false;
+        }
+    }
+
+    if ( out->disconnect() == false )
         return false;
+
     return true;
+
+}
+
+//
+// SLOTS DISCONNECTION
+//
+
+bool
+EffectNode::disconnectStaticVideoOutput( quint32 nodeId )
+{
+    QWriteLocker                        wl( &m_rwl );
+
+    return primitiveDisconnection( nodeId, "", false );
+}
+
+bool
+EffectNode::disconnectStaticVideoOutput( const QString & nodeName )
+{
+    QWriteLocker                        wl( &m_rwl );
+
+    return primitiveDisconnection( 0, nodeName, false );
+}
+
+//
+// INTERNALS SLOTS DISCONNECTION
+//
+
+bool
+EffectNode::disconnectInternalStaticVideoOutput( quint32 nodeId )
+{
+    QWriteLocker                        wl( &m_rwl );
+
+    return primitiveDisconnection( nodeId, "", true );
 }
 
 bool
 EffectNode::disconnectInternalStaticVideoOutput( const QString & nodeName )
 {
     QWriteLocker                        wl( &m_rwl );
-    OutSlot<LightVideoFrame>*  out;
-    InSlot<LightVideoFrame>*   in;
-    EffectNode*                father;
 
-    if ( ( out = m_internalsStaticVideosOutputs.getObject( nodeName ) ) == NULL )
-        return false;
-    in = out->getInSlotPtr();
-    if ( out->disconnect() == false )
-        return false;
-    if ( m_connectedInternalsStaticVideosOutputs.delObjectReference( out->getId() ) == false )
-        return false;
-    father = in->getPrivateFather();
-    if ( father->dereferenceStaticVideoInputAsConnected( in->getId() ) == false )
-        return false;
-    return true;
+    return primitiveDisconnection( 0, nodeName, true );
 }
 
 
diff --git a/src/EffectsEngine/EffectNode.h b/src/EffectsEngine/EffectNode.h
index 15204c2..1871f4b 100644
--- a/src/EffectsEngine/EffectNode.h
+++ b/src/EffectsEngine/EffectNode.h
@@ -323,7 +323,7 @@ class	EffectNode : public IEffectNode
     //     bool                areDynamicControlsOutputsEnabled( void ) const;
 
     //--------------------------------------------------------------------//
-    //      NORMALS CONNECT/DISCONNECT & BIND/UNBIND DYN/STAT SLOTS       //
+    //                    NORMALS CONNECT DYN/STAT SLOTS                  //
     //--------------------------------------------------------------------//
 
     // ----------------  CONNECT STATIC TO STATIC -------------------
@@ -367,14 +367,8 @@ class	EffectNode : public IEffectNode
     /* bool        connectDynamicVideoOutputToDynamicVideoInput( QString const & nodeName ); */
     /* bool        connectDynamicVideoOutputToDynamicVideoInput( quint32 nodeId ); */
 
-    // ----------------  DISCONNECT -------------------
-
-    /* bool        disconnectDynamicVideoOutput( void ); */
-    bool        disconnectStaticVideoOutput( quint32 nodeId );
-    bool        disconnectStaticVideoOutput( const QString & nodeName );
-
     //-------------------------------------------------------------------------//
-    //      CONNECT/DISCONNECT & BIND/UNBIND DYN/STAT SLOTS TO PARENTS         //
+    //                        CONNECT SLOTS TO PARENTS                         //
     //-------------------------------------------------------------------------//
 
     // ----------------  CONNECT STATIC TO STATIC -------------------
@@ -403,6 +397,21 @@ public:
 
     // ----------------  CONNECT DYNAMIC TO DYNAMIC -------------------
 
+    //-------------------------------------------------------------------------//
+    //                             DISCONNECTIONS                              //
+    //-------------------------------------------------------------------------//
+
+ private:
+    // ---------------- PRIMITIVE DISCONNECTION --------------------
+
+    bool        primitiveDisconnection( quint32 nodeId, const QString & nodeName, bool internal );
+
+ public:
+    // ---------------- EXTERNAL SLOTS DISCONNECTS --------------------
+
+    bool        disconnectStaticVideoOutput( quint32 nodeId );
+    bool        disconnectStaticVideoOutput( const QString & nodeName );
+
     // ---------------- INTERNALS SLOTS DISCONNECTS --------------------
 
     bool         disconnectInternalStaticVideoOutput( quint32 nodeId );



More information about the Vlmc-devel mailing list