Ignore:
Timestamp:
Jan 7, 2011, 5:41:45 PM (13 years ago)
Author:
Torben Dannhauer
Message:

XML configuration now works also with dataIO cluster

File:
1 edited

Legend:

Unmodified
Added
Removed
  • osgVisual/trunk/src/dataIO/visual_dataIO.cpp

    r160 r183  
    4949void visual_dataIO::init(osgViewer::Viewer* viewer_, osg::ArgumentParser& arguments_, std::string configFileName)
    5050{
    51         OSG_NOTIFY( osg::ALWAYS ) << "visual_dataIO initialize.." << std::endl;
     51        OSG_NOTIFY( osg::ALWAYS ) << "visual_dataIO initialize..";
    5252
    5353        // Init variables
     
    5656        // Process XML configuration
    5757        this->configFileName = configFileName;
    58         if(!processXMLConfiguration())
     58        xmlNode *extLinkConfig=NULL;
     59        if(!processXMLConfiguration(extLinkConfig))
    5960                OSG_FATAL << "ERROR: visual_dataIO::init() - Failed to initialize dataIO via XML configuration!";
    60 
    61 
    62         // Create Cluster.
    63         #ifdef USE_CLUSTER_ASIO_TCP_IOSTREAM
    64                 cluster = new dataIO_clusterAsioTcpIostream();
    65         #endif
    66         #ifdef USE_CLUSTER_ENET
    67                 cluster = new dataIO_clusterENet();
    68                 cluster->enableHardSync( false );       /** \todo : rebuild this structure in cluster.h and move it this way to a general implementation. */
    69         #endif
    70         #ifdef USE_CLUSTER_DUMMY
    71                 cluster = new dataIO_clusterDummy();
    72         #endif
    73         if(cluster.valid())
    74                 //cluster->init(arguments_, clusterMode, slotContainer, true, false);
    75                 cluster->init(arguments_, viewer_, clusterMode, slotContainer, false, false);
    7661
    7762        // Create extLink.
     
    8570
    8671       
    87 
    8872        // Install callbacks to perform DataIO activities every frame:
    8973        //// EventCallback at the absolute beginning of the frame
     
    9781}
    9882
    99 bool visual_dataIO::processXMLConfiguration()
     83bool visual_dataIO::processXMLConfiguration(xmlNode* extLinkConfig_)
    10084{
    10185        // Init XML
     
    10387        bool disabled;
    10488        xmlNode* config = util::getModuleXMLConfig( configFileName, "dataio", tmpDoc, disabled );
     89        xmlNode* clusterConfig = NULL;
    10590
    10691        if( disabled)
    10792                OSG_NOTIFY( osg::ALWAYS ) << "..disabled by XML configuration file. dataIO can't be disabled. Ignoring." << std::endl;
     93        else
     94                OSG_NOTIFY( osg::ALWAYS ) << std::endl;
    10895
    10996        // extract configuration values
     
    152139                        if(cur_node->type == XML_ELEMENT_NODE && node_name == "cluster")
    153140                        {
    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
     141                                // Pass cluster configuration to the used cluster implementation.
     142                                // The implementation will use the configuration if it matches, otherwise falls back to dummy cluster
     143                                clusterConfig = cur_node;
    157144                        }
    158145
     
    166153
    167154                }       // FOR all nodes END
     155
     156
     157
     158                // Create Cluster.
     159                #ifdef USE_CLUSTER_ASIO_TCP_IOSTREAM
     160                        cluster = new dataIO_clusterAsioTcpIostream();
     161                #endif
     162                #ifdef USE_CLUSTER_ENET
     163                        cluster = new dataIO_clusterENet();
     164                #endif
     165                if( !cluster.valid() || !clusterConfig || !cluster->init(clusterConfig, viewer, clusterMode, slotContainer, false) )
     166                {
     167                        cluster = new dataIO_clusterDummy();
     168                        cluster->init(clusterConfig, viewer, clusterMode, slotContainer, false);
     169                }
     170
     171
    168172
    169173                // clean up
     
    176180                return false;
    177181        }
    178 
    179182        return true;
    180183}
Note: See TracChangeset for help on using the changeset viewer.