#include <Context.h>
Inheritance diagram for ot::Context:


Finally it implements the main loop driving the tracker. This consists of the following basic algorithm described in pseudo code here :
start();
while( !stop())
{
pushEvents();
pullEvents();
}
close(); The Context also keeps track of various information. The following items are stored and used by modules :
The Context stores a stack of directories. Any module that needs to load a file can use the stack to find files relative to a number of directories. By default the stack contains the path component of the configuration file, followed by the current directory. See the method findFile for details.
Public Member Functions | |
| void | lock () |
| shortcut to stop the main loop by ackquiring the mutex | |
| void | unlock () |
| void | waitDataSignal () |
| methods for data driven traversal | |
| void | dataSignal () |
| void | dataBroadcast () |
| Context (int init=0) | |
| virtual | ~Context () |
| void | addFactory (NodeFactory &newfactory) |
| void | removeFactory (NodeFactory &factory) |
| void | addModule (const std::string &name, Module &module) |
| Module * | getModule (const std::string &name) |
| void | removeModule (Module &module) |
| Node * | createNode (const std::string &name, StringTable &attributes) |
| Node * | getRootNode () |
| Node * | findNode (const std::string &id) |
| void | parseConfiguration (const std::string &filename) |
| void | parseConfigurationString (const char *xmlstring) |
| void | start () |
| void | pushEvents () |
| void | pullEvents () |
| int | loopOnce () |
| void | run () |
| void | runAtRate (double rate) |
| void | runOnDemand () |
| int | stop () |
| void | stopLoop () |
| void | close () |
| void | addDirectoryFirst (const std::string &dir) |
| void | addDirectoryLast (const std::string &dir) |
| void | removeDirectory (const std::string &dir) |
| bool | findFile (const std::string &filename, std::string &fullname) |
| const std::string & | getRootNamespace () |
| const std::string & | getConfigFile () |
| void | newVideoFrame (const unsigned char *image, int width, int height, PIXEL_FORMAT format) |
| Called by a video providing instance to pass a new video frame into OpenTracker. | |
| void | registerVideoUser (VideoUser *videoUser) |
| Called by a module to register itself as a video user. | |
| void | unregisterVideoUser (VideoUser *videoUser) |
| Called by a module to unregister itself as a video user. | |
| void | copyFrom (Context &other) |
| void | addNode (std::string parentid, Node *newnode) |
| void | removeSubtree (std::string nodeid) |
| void | removeNode (std::string nodeid) |
| void | replaceNode (std::string nodeid, Node *newnode) |
| Module * | getModuleFromNode (const Node *node) |
| Module * | getModuleFromNodeType (std::string nodename) |
| bool | isConfigured () |
Protected Attributes | |
| ModuleMap | modules |
| A map of the modules this context works with. | |
| Node::Ptr | rootNode |
| Pointer to the root node of the local tracker tree. | |
| NodeFactoryContainer | factory |
| A NodeFactoryContainer used by the ConfigurationParser to create new nodes. | |
| bool | cleanUp |
| flag to remember whether the Context is responsible for cleaning up the modules. | |
| bool | stoploopflag |
| flag for stopping the main loop | |
| std::string | file |
| stores the filename of the current configuration. | |
| std::vector< std::string > | directories |
| stores a stack of directory names to search for files in | |
| std::string | rootNamespace |
| stores the namespace string of the root element | |
| VideoUserVector | videoUsers |
| ACE_Thread_Mutex * | _mutex |
| used for synchronization between the main loop and the reconfiguration scheme | |
| ACE_Thread_Mutex * | _havedatamutex |
| ACE_Condition_Thread_Mutex * | _havedatacondition |
Friends | |
| class | ConfigurationParser |
|
|
a constructor method.
|
|
|
destructor method clears containers and removes any modules instantiated in the default setup, if cleanUp is st. |
|
|
add a directory to the front of the directory stack
|
|
|
add a directory to the end of the directory stack
|
|
|
adds a new factory to the NodeFactoryContainer.
|
|
||||||||||||
|
adds a module to the contexts container.
|
|
||||||||||||
|
|
|
|
calls close on all modules to close any resources. |
|
|
Called by the Configurator upon reconfiguration. The other context contains the new configuration that must be copied by the running one. |
|
||||||||||||
|
This method creates a new node based on a given element name and a table of attributes. It will delegate the construction to the stored NodeFactory list and return a new Node, if one of the factories can create the desired type. Otherwise it returns NULL. It makes sure that the node is associated with this context, therefore this is the only way to create new nodes for the user.
|
|
|
|
|
|
|
|
||||||||||||
|
tries to locate a file by prepending the directory names in the stack. If a file at that location is found, the full name is returned in fullname and true will be returned. Otherwise fullname is not changed and false is returned.
|
|
|
returns the node with the given unique ID tag. If none is found NULL is returned.
|
|
|
|
|
|
returns the module associated with a certain configuration element
|
|
|
Obtain the Module responsible for a certain node, Notice that this may return NULL for nodes like EventUtilityNode, which are part of opentracker |
|
|
Obtain the Module responsible for a node of type nodename. It might return NULL for nodes like EventUtilityNode which are part of opentracker (but have no Module) |
|
|
returns the XML namespace of the root element
|
|
|
returns the root node, that contains the tracker tree. This node is an instance of the generic node class and only deal with the children API. It does also contain the configuration element in the first node.
|
|
|
|
|
|
shortcut to stop the main loop by ackquiring the mutex
|
|
|
do one atomic cycle of the OpenTracker loop, returns the value of of stop(), to indicate whether the main loop needs to be stopped. Introduced for reconfiguration purposes, it is not safe to call pushEvent(), pullEvent(), and stop() separatelly, since the configuration may change between calls. For safety use loopOnce() and test the return. |
|
||||||||||||||||||||
|
Called by a video providing instance to pass a new video frame into OpenTracker.
|
|
|
This method initialies the context with a tracker tree described by a configuration file. It parses the file and builds the tree.
|
|
|
|
|
|
calls pullSEvent on all modules to get data out again. |
|
|
This method calls pushEvent on all moadules to get new data into the shared data tree. |
|
|
Called by a module to register itself as a video user.
|
|
|
remove a directory from the directory stack
|
|
|
removes a factory from the NodeFactoryContainer.
|
|
|
removes a module from the map
|
|
|
|
|
|
|
|
||||||||||||
|
|
|
|
This method implements the main loop and runs until it is stopped somehow. Then it calls close() on all modules. Reimplemented in ot::LiveContext, and ot::ThreadContext. |
|
|
This method implements the main loop in a way that it is run at a specificed rate until it is stopped somehow. Then it calls close() on all modules. Reimplemented in ot::ThreadContext. |
|
|
This is a data-driven implementation of the main loop Reimplemented in ot::ThreadContext. |
|
|
calls start on all modules to do some initialization. |
|
|
tests whether the mainloop should stop, by asking all modules whether they need to stop. |
|
|
sets a termination flag for the main loop |
|
|
|
|
|
Called by a module to unregister itself as a video user.
|
|
|
methods for data driven traversal
|
|
|
Reimplemented in ot::ThreadContext. |
|
|
|
|
|
used for synchronization in data-driven traversal in this case the graph is only traversed if some event-driven enabled event generator node produces new data |
|
|
used for synchronization between the main loop and the reconfiguration scheme
|
|
|
flag to remember whether the Context is responsible for cleaning up the modules.
|
|
|
stores a stack of directory names to search for files in
|
|
|
A NodeFactoryContainer used by the ConfigurationParser to create new nodes.
|
|
|
stores the filename of the current configuration.
|
|
|
A map of the modules this context works with.
|
|
|
stores the namespace string of the root element
|
|
|
Pointer to the root node of the local tracker tree.
|
|
|
flag for stopping the main loop
|
|
|
|
1.4.6