OpenTracker

An Open Architecture for Reconfigurable Tracking based on XML | Contact

GroupGateNode.cxx

Go to the documentation of this file.
00001 /* ========================================================================
00002  * Copyright (c) 2006,
00003  * Institute for Computer Graphics and Vision
00004  * Graz University of Technology
00005  * All rights reserved.
00006  *
00007  * Redistribution and use in source and binary forms, with or without
00008  * modification, are permitted provided that the following conditions are
00009  * met:
00010  *
00011  * Redistributions of source code must retain the above copyright notice,
00012  * this list of conditions and the following disclaimer.
00013  *
00014  * Redistributions in binary form must reproduce the above copyright
00015  * notice, this list of conditions and the following disclaimer in the
00016  * documentation and/or other materials provided with the distribution.
00017  *
00018  * Neither the name of the Graz University of Technology nor the names of
00019  * its contributors may be used to endorse or promote products derived from
00020  * this software without specific prior written permission.
00021  *
00022  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
00023  * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
00024  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
00025  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
00026  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00027  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00028  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00029  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00030  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00031  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00032  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00033  * ========================================================================
00034  * PROJECT: OpenTracker
00035  * ======================================================================== */
00043 /* ======================================================================= */
00044 
00045 // this will remove the warning 4786
00046 #include "../tool/disable4786.h"
00047 
00048 #include <stdlib.h>
00049 #include "GroupGateNode.h"
00050 
00051 #include <stdio.h>
00052 #include <iostream>
00053 
00054 #include <ace/Log_Msg.h>
00055 
00056 
00057 #ifndef OT_NO_GROUPGATE_SUPPORT
00058 
00059 
00060 namespace ot {
00061 
00062     // constructor method
00063     GroupGateNode::GroupGateNode(const char *name, GroupGateGroup *owner)
00064     {
00065         Number = -1;
00066         Name = name;
00067         Owner = owner;
00068         IsActive = false;
00069     } 
00070 
00071     GroupGateNode::~GroupGateNode()
00072     {
00073         Neighbors.clear();
00074     } 
00075 
00076     void
00077     GroupGateNode::setNumber(int num)
00078     {
00079         Number = num;
00080     }
00081 
00082     int
00083     GroupGateNode::getNumber()
00084     {
00085         return Number;
00086     }
00087 
00088     void 
00089     GroupGateNode::addNeighbor(const char *neighbor)
00090     {
00091         Neighbors.push_back(neighbor);
00092     }
00093 
00094     bool
00095     GroupGateNode::isActive()
00096     {
00097         return IsActive;
00098     }
00099 
00100     void
00101     GroupGateNode::activate()
00102     {
00103         IsActive = true;
00104     }
00105 
00106     void
00107     GroupGateNode::deactivate()
00108     {
00109         IsActive = false;
00110     }
00111 
00112     const char *
00113     GroupGateNode::getGroupGateName()
00114     {
00115         return (Name.c_str());
00116     }
00117 
00118     void 
00119     GroupGateNode::onEventGenerated(Event &event, Node &generator)
00120     {
00121         if (generator.isNodePort() == 1)
00122         {
00123             NodePort &wrap = (NodePort &)generator;
00124             if (wrap.getType().compare("Override") == 0)
00125             {
00126                 Owner->deactivateAll();
00127                 activate();
00128                 Owner->setActiveGroupGate(this);
00129                 Owner->notifyActiveGate();
00130                 updateObservers(event);
00131                 return;
00132             }
00133         }
00134         if (isActive())
00135         {
00136             activate();
00137             Owner->notifyActiveGate();
00138             updateObservers(event);
00139             return;
00140         }
00141         else
00142         {
00143             if (Neighbors.size() != NeighborPtrs.size())
00144             {
00145                 for (NeighborsVector::iterator it = Neighbors.begin(); it != Neighbors.end(); it++)
00146                 {
00147                     GroupGateNode *node = (GroupGateNode *)(Owner->getNode((* it).c_str()));
00148                     NeighborPtrs.push_back(node);
00149                 }
00150                 if (Neighbors.size() != NeighborPtrs.size())                
00151                     ACE_DEBUG((LM_ERROR, ACE_TEXT("ot:ERROR: Problem with GroupGateNode\n")));
00152             }
00153             for (NeighborPtrsVector::iterator it = NeighborPtrs.begin(); it != NeighborPtrs.end(); it++)
00154             {
00155                 GroupGateNode *node = (GroupGateNode *)(* it);
00156                 if (node->isActive())
00157                 {
00158                     node->deactivate();
00159                     activate();
00160                     Owner->setActiveGroupGate(this);
00161                     Owner->notifyActiveGate();
00162                     updateObservers(event);
00163                     return;
00164                 }
00165             }
00166             /*
00167               for (NeighborsVector::iterator it = Neighbors.begin(); it != Neighbors.end(); it++)
00168               {
00169               GroupGateNode *node = (GroupGateNode *)(Owner->getNode((* it).c_str()));
00170               if (node->isActive())
00171               {
00172               node->deactivate();
00173               activate();
00174               Owner->setActiveGroupGate(this);
00175               Owner->notifyActiveGate();
00176               updateObservers(event);
00177               return;
00178               }
00179               }
00180             */
00181         }
00182     }
00183 
00184 } // namespace ot {
00185 
00186 
00187 #else
00188 #pragma message(">>> OT_NO_GROUPGATE_SUPPORT")
00189 #endif //OT_NO_GROUPGATE_SUPPORT
00190 
00191 /* 
00192  * ------------------------------------------------------------
00193  *   End of GroupGateNode.cxx
00194  * ------------------------------------------------------------
00195  *   Automatic Emacs configuration follows.
00196  *   Local Variables:
00197  *   mode:c++
00198  *   c-basic-offset: 4
00199  *   eval: (c-set-offset 'substatement-open 0)
00200  *   eval: (c-set-offset 'case-label '+)
00201  *   eval: (c-set-offset 'statement 'c-lineup-runin-statements)
00202  *   eval: (setq indent-tabs-mode nil)
00203  *   End:
00204  * ------------------------------------------------------------ 
00205  */

copyright (c) 2006 Graz University of Technology