Changeset 160 for osgVisual


Ignore:
Timestamp:
Nov 14, 2010, 6:32:43 PM (13 years ago)
Author:
Torben Dannhauer
Message:

change dataIO configuration from command line to xml File.

Status: in Progress

Location:
osgVisual
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • osgVisual/bin/osgVisualConfig.xml

    r157 r160  
    2727        standalone: This role recieves all relevant data via the extLink and renders it. No cluster functionality is used.
    2828    -->
    29     <dataio clusterrole="master"></dataio>
     29    <dataio clusterrole="standalone"></dataio>
    3030    <cluster implementation="enet" master_ip="10.10.10.10" port="1234" use_zlib_compressor="yes" ></cluster>
    31     <extLink implementation="vcl" filename="osgVisual.xml"></extLink>
     31    <extlink implementation="vcl" filename="osgVisual.xml"></extlink>
    3232  </module>
    3333 
  • osgVisual/include/dataIO/visual_dataIO.h

    r158 r160  
    2222#include <osgViewer/Viewer>
    2323
     24// osgVisual specifiy includes
     25#include <visual_util.h>
     26
    2427// Cluster
    2528#ifdef USE_CLUSTER_ASIO_TCP_IOSTREAM
     
    177180
    178181        /**
     182         * XML config filename
     183         */
     184        std::string configFileName;
     185
     186        /**
    179187         * The eventCallback-class is friend to be able to work with all dataIO members without setters/getters.
    180188         */
  • osgVisual/src/dataIO/visual_dataIO.cpp

    r157 r160  
    4949void visual_dataIO::init(osgViewer::Viewer* viewer_, osg::ArgumentParser& arguments_, std::string configFileName)
    5050{
    51         OSG_NOTIFY( osg::ALWAYS ) << "visual_dataIO init()" << std::endl;
     51        OSG_NOTIFY( osg::ALWAYS ) << "visual_dataIO initialize.." << std::endl;
    5252
    5353        // Init variables
     
    5555
    5656        // Process XML configuration
     57        this->configFileName = configFileName;
    5758        if(!processXMLConfiguration())
    58                 OSG_FATAL << "ERROR: visual_dataIO::init() - Failed to initialize dataIO!";
    59 
    60         // Parse operating Mode
    61     if (arguments_.read("-m"))
    62         {
    63                 OSG_NOTIFY( osg::ALWAYS ) << "Configure osgVisual as MASTER" << std::endl;
    64                 clusterMode = osgVisual::dataIO_cluster::MASTER;
    65         }
    66         else if (arguments_.read("-s"))
    67         {
    68                 OSG_NOTIFY( osg::ALWAYS ) << "Configure osgVisual as SLAVE" << std::endl;
    69                 clusterMode = osgVisual::dataIO_cluster::SLAVE;
    70                 slotContainer = NULL;   // Slave only recieves container, therefor set this Pointer NULL (created instance will be deleted because it is an auto pointer).
    71         }
    72         else
    73         {
    74                 OSG_NOTIFY( osg::ALWAYS ) << "Configure osgVisual as STANDALONE" << std::endl;
    75                 clusterMode = osgVisual::dataIO_cluster::STANDALONE;
    76         }
     59                OSG_FATAL << "ERROR: visual_dataIO::init() - Failed to initialize dataIO via XML configuration!";
     60
    7761
    7862        // Create Cluster.
     
    11599bool visual_dataIO::processXMLConfiguration()
    116100{
     101        // Init XML
     102        xmlDoc* tmpDoc;
     103        bool disabled;
     104        xmlNode* config = util::getModuleXMLConfig( configFileName, "dataio", tmpDoc, disabled );
     105
     106        if( disabled)
     107                OSG_NOTIFY( osg::ALWAYS ) << "..disabled by XML configuration file. dataIO can't be disabled. Ignoring." << std::endl;
     108
     109        // extract configuration values
     110        if(config)
     111        {
     112                xmlNode* a_node = config->children;
     113
     114                for (xmlNode *cur_node = a_node; cur_node; cur_node = cur_node->next)
     115                {
     116                        std::string node_name=reinterpret_cast<const char*>(cur_node->name);
     117                        //OSG_ALWAYS << "----visual_distortion::processXMLConfiguration() - node type="<< cur_node->type <<", name=" << cur_node->name << std::endl;
     118
     119                        // Check for dataio node
     120                        if(cur_node->type == XML_ELEMENT_NODE && node_name == "dataio")
     121                        {
     122                                // Extract cluster role
     123                                xmlAttr  *attr = cur_node->properties;
     124                                while ( attr )
     125                                {
     126                                        std::string attr_name=reinterpret_cast<const char*>(attr->name);
     127                                        std::string attr_value=reinterpret_cast<const char*>(attr->children->content);
     128                                        if( attr_name == "clusterrole" )
     129                                        {
     130                                                if(attr_value == "master")
     131                                                {
     132                                                        OSG_NOTIFY( osg::ALWAYS ) << "Configure osgVisual as MASTER" << std::endl;
     133                                                        clusterMode = osgVisual::dataIO_cluster::MASTER;
     134                                                }
     135                                                else if(attr_value == "slave")
     136                                                {
     137                                                        OSG_NOTIFY( osg::ALWAYS ) << "Configure osgVisual as SLAVE" << std::endl;
     138                                                        clusterMode = osgVisual::dataIO_cluster::SLAVE;
     139                                                        slotContainer = NULL;   // Slave only recieves container, therefor set this Pointer NULL (created instance will be deleted because it is an auto pointer).
     140                                                }
     141                                                else if(attr_value == "standalone")
     142                                                {
     143                                                        OSG_NOTIFY( osg::ALWAYS ) << "Configure osgVisual as STANDALONE" << std::endl;
     144                                                        clusterMode = osgVisual::dataIO_cluster::STANDALONE;
     145                                                }
     146                                        }
     147                                        attr = attr->next;
     148                                }       // WHILE attrib END
     149                        }
     150
     151                        // Check for cluster node
     152                        if(cur_node->type == XML_ELEMENT_NODE && node_name == "cluster")
     153                        {
     154                                // Check Attributes to determine if the dummy implementation or any other implementation must be instantiated
     155
     156                                // Pass XML attributes to cluster to analyse and configure it by cluster itself
     157                        }
     158
     159                        // Check for extLink node
     160                        if(cur_node->type == XML_ELEMENT_NODE && node_name == "extlink")
     161                        {
     162                                // Check Attributes to determine if the dummy implementation or any other implementation must be instantiated
     163
     164                                // Pass XML attributes to extlink to analyse and configure it by extLink itself
     165                        }
     166
     167                }       // FOR all nodes END
     168
     169                // clean up
     170                xmlFreeDoc(tmpDoc); xmlCleanupParser();
     171                return true;
     172        }       // IF Config valid END
     173        else
     174        {
     175                OSG_WARN << "ERROR: visual_data::processXMLConfiguration() - Module configuration not found" << std::endl;
     176                return false;
     177        }
    117178
    118179        return true;
Note: See TracChangeset for help on using the changeset viewer.