Changeset 186 for osgVisual/trunk


Ignore:
Timestamp:
Jan 8, 2011, 8:13:43 PM (13 years ago)
Author:
Torben Dannhauer
Message:

XML configuration now works also with dataIO extLink

Location:
osgVisual/trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • osgVisual/trunk/include/cluster/dataIO_cluster.h

    r185 r186  
    6969
    7070        /**
    71          * \brief Pure virtual function for initialization. Must be implemented in derived class.
     71         * \brief Pure virtual function for XML configuration. Must be implemented in derived class.
    7272         *
    7373         */
     
    8282
    8383        /**
    84          * \brief Pure virtual function for initialization. Must be implemented in derived class.
     84         * \brief Pure virtual function for shutdown. Must be implemented in derived class.
    8585         *
    8686         */
  • osgVisual/trunk/include/dataIO/visual_dataIO.h

    r185 r186  
    133133         * @return : True if parsing was successful.
    134134         */
    135         bool processXMLConfiguration(xmlNode* extLinkConfig_);
     135        bool processXMLConfiguration();
    136136
    137137        /**
  • osgVisual/trunk/include/extLink/dataIO_extLink.h

    r118 r186  
    1919#include <osg/Node>
    2020#include <dataIO_slot.h>
     21
     22// XML Parser
     23#include <stdio.h>
     24#include <libxml/parser.h>
     25#include <libxml/tree.h>
    2126
    2227
     
    5459         *
    5560         */
    56         virtual void init() = 0;
     61        virtual bool init( xmlNode* configurationNode) = 0;
    5762
     63        /**
     64         * \brief Pure virtual function for XML configuration. Must be implemented in derived class.
     65         *
     66         */
     67        virtual bool processXMLConfiguration(xmlNode* extLinkConfig_) = 0;
     68
     69        /**
     70         * \brief Pure virtual function for shutdown. Must be implemented in derived class.
     71         *
     72         */
    5873        virtual void shutdown() = 0;
    5974
  • osgVisual/trunk/include/extLink/dataIO_extLinkDummy.h

    r132 r186  
    3737        virtual ~dataIO_extLinkDummy(void);
    3838
    39         void init();
     39        bool processXMLConfiguration(xmlNode* extLinkConfig_);
     40        bool init(xmlNode* configurationNode);
    4041        void shutdown();
    4142
  • osgVisual/trunk/include/extLink/dataIO_extLinkVCL.h

    r180 r186  
    7979        virtual ~dataIO_extLinkVCL(void);
    8080
    81         void init();
     81        bool init(xmlNode* configurationNode);
     82        bool processXMLConfiguration(xmlNode* extLinkConfig_);
    8283        void shutdown();
    8384
  • osgVisual/trunk/src/cluster/dataIO_clusterDummy.cpp

    r183 r186  
    3232{
    3333        sendContainer = sendContainer_;
    34         OSG_NOTIFY( osg::ALWAYS ) << "clusterDummy init();" << std::endl;
     34        OSG_NOTIFY( osg::ALWAYS ) << "clusterDummy init()" << std::endl;
    3535        return true;
    3636}
     
    3838bool dataIO_clusterDummy::processXMLConfiguration(xmlNode* clusterConfig_)
    3939{
    40         OSG_NOTIFY( osg::ALWAYS ) << "clusterDummy processXMLConfiguration();" << std::endl;
     40        OSG_NOTIFY( osg::ALWAYS ) << "clusterDummy processXMLConfiguration()" << std::endl;
    4141        return true;
    4242}
  • osgVisual/trunk/src/cluster/dataIO_clusterENet.cpp

    r185 r186  
    109109bool dataIO_clusterENet::processXMLConfiguration(xmlNode* clusterConfig_)
    110110{
    111                                 // Extract cluster role
    112                                 xmlAttr  *attr = clusterConfig_->properties;
    113                                 while ( attr )
    114                                 {
    115                                         std::string attr_name=reinterpret_cast<const char*>(attr->name);
    116                                         std::string attr_value=reinterpret_cast<const char*>(attr->children->content);
    117                                         if( attr_name == "implementation" )
    118                                         {
    119                                                 if(attr_value != "enet")
    120                                                 {
    121                                                         OSG_NOTIFY( osg::ALWAYS ) << "WARNING: Cluster configuration does not match the currently used 'enet' implementation, falling back to clusterDummy" << std::endl;
    122                                                         return false;
    123                                                 }
    124                                         }
    125                                         if( attr_name == "hardsync" )
    126                                         {
    127                                                 if(attr_value == "yes")
    128                                                         hardSync = true;
    129                                                 else
    130                                                         hardSync = false;
    131                                         }
    132                                         if( attr_name == "master_ip" )
    133                                         {
    134                                                 serverToConnect = attr_value;
    135                                         }
    136                                         if( attr_name == "port" )
    137                                         {
    138                                                 std::istringstream i(attr_value);
    139                                                 if (!(i >> port))
    140                                                 {
    141                                                         OSG_NOTIFY( osg::ALWAYS ) << "WARNING: Cluster configuration : Invalid port number '" << attr_value << "', falling back to clusterDummy" << std::endl;
    142                                                         return false;
    143                                                 }
    144                                         }
    145                                         if( attr_name == "use_zlib_compressor" )
    146                                         {
    147                                                 if(attr_value == "yes")
    148                                                         compressionEnabled = true;
    149                                                 else
    150                                                         compressionEnabled = false;
    151                                         }
    152                                         attr = attr->next;
    153                                 }       // WHILE attrib END
     111        // Extract cluster role
     112        xmlAttr  *attr = clusterConfig_->properties;
     113        while ( attr )
     114        {
     115                std::string attr_name=reinterpret_cast<const char*>(attr->name);
     116                std::string attr_value=reinterpret_cast<const char*>(attr->children->content);
     117                if( attr_name == "implementation" )
     118                {
     119                        if(attr_value != "enet")
     120                        {
     121                                OSG_NOTIFY( osg::ALWAYS ) << "WARNING: Cluster configuration does not match the currently used 'enet' implementation, falling back to clusterDummy" << std::endl;
     122                                return false;
     123                        }
     124                }
     125                if( attr_name == "hardsync" )
     126                {
     127                        if(attr_value == "yes")
     128                                hardSync = true;
     129                        else
     130                                hardSync = false;
     131                }
     132                if( attr_name == "master_ip" )
     133                {
     134                        serverToConnect = attr_value;
     135                }
     136                if( attr_name == "port" )
     137                {
     138                        std::istringstream i(attr_value);
     139                        if (!(i >> port))
     140                        {
     141                                OSG_NOTIFY( osg::ALWAYS ) << "WARNING: Cluster configuration : Invalid port number '" << attr_value << "', falling back to clusterDummy" << std::endl;
     142                                return false;
     143                        }
     144                }
     145                if( attr_name == "use_zlib_compressor" )
     146                {
     147                        if(attr_value == "yes")
     148                                compressionEnabled = true;
     149                        else
     150                                compressionEnabled = false;
     151                }
     152                attr = attr->next;
     153        }       // WHILE attrib END
    154154
    155155        return true;
  • osgVisual/trunk/src/dataIO/visual_dataIO.cpp

    r185 r186  
    5454        viewer = viewer_;
    5555
    56         // Process XML configuration
     56        // Process XML configuration - all XML dependen initializations are performed in processXMLConfiguration()
    5757        this->configFileName = configFileName;
    58         xmlNode *extLinkConfig=NULL;
    59         if(!processXMLConfiguration(extLinkConfig))
     58        if(!processXMLConfiguration())
    6059                OSG_FATAL << "ERROR: visual_dataIO::init() - Failed to initialize dataIO via XML configuration!";
    6160
    62         // Create extLink.
    63         #ifdef USE_EXTLINK_DUMMY
    64                 extLink = new dataIO_extLinkDummy( dataSlots );
    65         #endif
    66         #ifdef USE_EXTLINK_VCL
    67                 extLink = new dataIO_extLinkVCL( dataSlots );
    68         #endif
    69         extLink->init();
    70 
    71        
    7261        // Install callbacks to perform DataIO activities every frame:
    7362        //// EventCallback at the absolute beginning of the frame
     
    8170}
    8271
    83 bool visual_dataIO::processXMLConfiguration(xmlNode* extLinkConfig_)
     72bool visual_dataIO::processXMLConfiguration()
    8473{
    8574        // Init XML
     
    8776        bool disabled;
    8877        xmlNode* config = util::getModuleXMLConfig( configFileName, "dataio", tmpDoc, disabled );
    89         xmlNode* clusterConfig = NULL;
     78        xmlNode* clusterConfig = NULL, *extLinkConfig = NULL;
    9079
    9180        if( disabled)
     
    147136                        if(cur_node->type == XML_ELEMENT_NODE && node_name == "extlink")
    148137                        {
    149                                 // Check Attributes to determine if the dummy implementation or any other implementation must be instantiated
    150 
    151                                 // Pass XML attributes to extlink to analyse and configure it by extLink itself
     138                                // Pass extLink configuration to the used extLink implementation.
     139                                // The implementation will use the configuration if it matches, otherwise falls back to dummy extLink
     140                                extLinkConfig = cur_node;
    152141                        }
    153142
    154143                }       // FOR all nodes END
    155 
    156144
    157145
     
    169157                }
    170158
     159                // Create extLink.
     160                #ifdef USE_EXTLINK_VCL
     161                        extLink = new dataIO_extLinkVCL( dataSlots );
     162                #endif
     163                if( !extLink.valid() || !extLinkConfig || !extLink->init(extLinkConfig) )
     164                {
     165                        extLink = new dataIO_extLinkDummy( dataSlots );
     166                        extLink->init(extLinkConfig);
     167                }
    171168
    172169
  • osgVisual/trunk/src/extLink/dataIO_extLinkDummy.cpp

    r132 r186  
    3232}
    3333
    34 void dataIO_extLinkDummy::init()
     34bool dataIO_extLinkDummy::init(xmlNode* configurationNode)
    3535{
    3636        OSG_NOTIFY( osg::ALWAYS ) << "extLinkDummy init()" << std::endl;
     37        return true;
     38}
     39
     40bool dataIO_extLinkDummy::processXMLConfiguration(xmlNode* extLinkConfig_)
     41{
     42        OSG_NOTIFY( osg::ALWAYS ) << "extLinkDummy processXMLConfiguration()" << std::endl;
     43        return true;
    3744}
    3845
  • osgVisual/trunk/src/extLink/dataIO_extLinkVCL.cpp

    r121 r186  
    3131}
    3232
    33 void dataIO_extLinkVCL::init()
    34 {
     33bool dataIO_extLinkVCL::init(xmlNode* configurationNode)
     34{
     35        if (!configurationNode || !processXMLConfiguration(configurationNode))
     36                return false;
     37
    3538        OSG_NOTIFY( osg::ALWAYS ) << "extLinkVCL init()" << std::endl;
    3639
    37         VCLConfigFilename = "osgVisual.xml";
    38        
    3940        if ( osgDB::fileExists( VCLConfigFilename ) )
    4041        {
     
    4748        else
    4849        {
    49                 OSG_NOTIFY( osg::FATAL ) << "ERROR: Could not find VCL Configuration file " << VCLConfigFilename << std::endl;
    50                 exit(-1);
    51         }
    52 
     50                OSG_NOTIFY( osg::FATAL ) << "ERROR: Could not find VCL Configuration file '" << VCLConfigFilename << "', falling back to extLinkDummy" << std::endl;
     51                return false;
     52        }
     53        return true;
     54}
     55
     56bool dataIO_extLinkVCL::processXMLConfiguration(xmlNode* extLinkConfig_)
     57{
     58        // Extract VCL config file
     59        xmlAttr  *attr = extLinkConfig_->properties;
     60        while ( attr )
     61        {
     62                std::string attr_name=reinterpret_cast<const char*>(attr->name);
     63                std::string attr_value=reinterpret_cast<const char*>(attr->children->content);
     64                if( attr_name == "implementation" )
     65                {
     66                        if(attr_value != "vcl")
     67                        {
     68                                OSG_NOTIFY( osg::ALWAYS ) << "WARNING: extLink configuration does not match the currently used 'vcl' implementation, falling back to extLinkDummy" << std::endl;
     69                                return false;
     70                        }
     71                }
     72                if( attr_name == "filename" )
     73                {
     74                        VCLConfigFilename = attr_value;
     75                }
     76                attr = attr->next;
     77        }       // WHILE attrib END
     78
     79        return true;
    5380}
    5481
Note: See TracChangeset for help on using the changeset viewer.