OpenTracker

An Open Architecture for Reconfigurable Tracking based on XML | Contact

Node.h

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  * ======================================================================== */
00042 /* ======================================================================= */
00043 
00044 #ifndef _NODE_H
00045 #define _NODE_H
00046 
00047 #include "../dllinclude.h"
00048 
00058 #include <string>
00059 #include <vector>
00060 
00061 namespace ot {
00062 
00063     class Context;
00064     class ConfigurationParser;
00065     class RefNode;
00066     class Node;
00067     class NodePort;
00068 
00069 } // namespace ot
00070 
00071 #include "Event.h"
00072 
00073 namespace ot {
00074 
00080     typedef std::vector<Node *> NodeVector;
00081 
00082 
00092     class OPENTRACKER_API Node
00093     {
00094 
00095     protected:
00097         void * parent;
00098 
00100         NodeVector references;
00101 
00103         std::string name;
00104 
00106         std::string type;
00107 
00108     public:
00110         enum error { OK=0,              
00111                      GRAPH_CONSTRAINT,  
00112                      READONLY,          
00113                      CONTEXT_ERROR,     
00114                      NOT_FOUND          
00115         };
00116 
00117     protected:
00118 
00119         virtual void setParent( void * parElement );
00120 
00126         void addReference( Node * reference );
00127 
00132         void removeReference( Node * reference );
00133 
00142         Node();
00143 
00151 
00152     public:
00156         const std::string get( const std::string & key ) const;
00166         int get(const std::string & key, int * value, int len = 1 ) const;
00176         int get(const std::string & key, float * value, int len = 1 ) const;
00186         int get(const std::string & key, double * value, int len = 1 ) const;
00187 
00188     protected:
00193         void put( const std::string &key, const std::string &value );
00197         void remove( const std::string &key );
00198 
00205         void put(const std::string & key, const int value);
00212         void put(const std::string & key, const float value);
00219         void put(const std::string & key, const double value);
00220 
00229         void put(const std::string & key, const int * value, int len);
00238         void put(const std::string & key, const float * value, int len);
00247         void put(const std::string & key, const double * value, int len);
00249 
00250     public:
00251 
00255         virtual ~Node();
00256 
00263         const std::string & getType() const
00264         {
00265             return type;
00266         }
00267 
00273         const std::string & getName() const
00274         {
00275             return name;
00276         }
00277 
00282         Context * getContext() const;
00283 
00288 
00296         Node * getParent();
00297 
00302         unsigned int countChildren();
00303 
00310         Node * getChild( unsigned int index );
00311 
00318         error addChild(Node & child);
00319 
00327         error removeChild(Node & child);
00328 
00334         unsigned int countPorts();
00335 
00343         NodePort * getPort( const std::string & name, unsigned int index = 0 );
00344 
00351         NodePort * getPort( unsigned int index );
00352 
00359         error addPort( const std::string & name );
00360 
00368         error removePort( const std::string & name );
00369 
00370         error removePort( NodePort & port);
00371 
00372         error removePort( unsigned int index );
00373 
00375 
00383 
00391         virtual int isEventGenerator()
00392         {
00393             return 0;
00394         }
00395 
00404         virtual void onEventGenerated( Event& event, Node& generator)
00405         {
00406         }
00407 
00414         void updateObservers( Event &data );
00415 
00417 
00426 
00433         virtual int isEventQueue()
00434         {
00435             return 0;
00436         }
00443         virtual Event& getEvent(unsigned int index = 0)
00444         {
00445             return Event::null;
00446         }
00451         virtual Event& getEventNearTime(double time)
00452         {
00453             return Event::null;
00454         }
00458         virtual unsigned int getSize()
00459         {
00460             return 0;
00461         }
00462 
00464 
00471 
00478         virtual int isTimeDependend()
00479         {
00480             return 0;
00481         }
00482 
00488         virtual Event& getEventAtTime(double time)
00489         {
00490             return Event::null;
00491         }
00492 
00494 
00502         virtual int isNodePort()
00503         {
00504             return 0;
00505         }
00506 
00507         friend class Context;
00508         friend class ConfigurationParser;
00509         friend class RefNode;
00510         friend class XMLWriter;
00511     };
00512 
00513 } // namespace ot
00514 
00515 #endif
00516 
00517 /* 
00518  * ------------------------------------------------------------
00519  *   End of Node.h
00520  * ------------------------------------------------------------
00521  *   Automatic Emacs configuration follows.
00522  *   Local Variables:
00523  *   mode:c++
00524  *   c-basic-offset: 4
00525  *   eval: (c-set-offset 'substatement-open 0)
00526  *   eval: (c-set-offset 'case-label '+)
00527  *   eval: (c-set-offset 'statement 'c-lineup-runin-statements)
00528  *   eval: (setq indent-tabs-mode nil)
00529  *   End:
00530  * ------------------------------------------------------------ 
00531  */

copyright (c) 2006 Graz University of Technology