Changeset 152


Ignore:
Timestamp:
Nov 9, 2010, 10:56:41 PM (13 years ago)
Author:
Torben Dannhauer
Message:

Silverlining, Distortion now uses XMl configuration file for configuration.

Todo: vista2D and the whole dataIO tree.

Location:
osgVisual
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • osgVisual/include/util/visual_util.h

    r151 r152  
    239239         * @param moduleName : Module name to search for.
    240240         * @param doc : xmlDoc to use. Must be created outside that the caller can clean it up.
     241         * @param disabled : Contains after return if the module was disabled. Only true if valid configuration and definitely disabled.
    241242         * @return : NULL on error, otherwise pointer to the xmlNode of the queried module.
    242243         */
    243         static xmlNode* getModuleXMLConfig(std::string configFilename, std::string moduleName, xmlDoc*& doc);
     244        static xmlNode* getModuleXMLConfig(std::string configFilename, std::string moduleName, xmlDoc*& doc, bool& disabled);
    244245
    245246        /**
     
    260261         * @param node : Node to search in
    261262         * @param moduleName :Module name to search for.
     263         * @param disabled : Contains after return if the module was disabled. Only true if valid configuration and definitely disabled.
    262264         * @return : NULL if the module configuration was not found, otherwise pointer to the XML Node with the configuration for the specified module.
    263265         */
    264         static xmlNode* checkXMLNodeChildrenForModule(xmlNode* node, std::string moduleName);
     266        static xmlNode* checkXMLNodeChildrenForModule(xmlNode* node, std::string moduleName, bool& disabled);
    265267
    266268        /**
  • osgVisual/src/distortion/visual_distortion.cpp

    r151 r152  
    4444        // Init XML
    4545        xmlDoc* tmpDoc;
    46         xmlNode* config = util::getModuleXMLConfig( configFileName, "distortion", tmpDoc );
     46        bool disabled;
     47        xmlNode* config = util::getModuleXMLConfig( configFileName, "distortion", tmpDoc, disabled );
     48
     49        if( disabled)
     50        {
     51                OSG_NOTIFY( osg::ALWAYS ) << "..disabled by XML configuration file." << std::endl;
     52                return false;
     53        }
    4754       
    4855        // extract configuration values
    4956        if(config)
    5057        {
    51                 OSG_NOTIFY( osg::ALWAYS ) << "Using distortion." << std::endl;
     58                OSG_NOTIFY( osg::ALWAYS ) << "..using distortion." << std::endl;
    5259
    5360                xmlNode* a_node = config->children;
     
    164171        else
    165172        {
    166                 OSG_WARN << "WARNING: visual_distortion::processXMLConfiguration() - Module configuration not found or module disabled!" << std::endl;
     173                OSG_WARN << "ERROR: visual_distortion::processXMLConfiguration() - Module configuration not found" << std::endl;
    167174                return false;
    168175        }
     
    175182osg::Group* visual_distortion::initialize(osg::Group* subgraph, const osg::Vec4& clearColor )
    176183{
    177         OSG_NOTIFY (osg::ALWAYS ) << "visual_distortion initialize..." << std::endl;
     184        OSG_NOTIFY (osg::ALWAYS ) << "visual_distortion initialize..";  // The sentence is finished by the init result...
    178185
    179186        // Initialize variables:
  • osgVisual/src/util/visual_util.cpp

    r151 r152  
    8989}
    9090
    91 xmlNode* util::getModuleXMLConfig(std::string configFilename, std::string moduleName, xmlDoc*& doc)
     91xmlNode* util::getModuleXMLConfig(std::string configFilename, std::string moduleName, xmlDoc*& doc, bool& disabled)
    9292{
    9393        doc = NULL;
     94        disabled = false;
    9495        xmlNode *root_element = NULL;
    9596
     
    126127
    127128        // If file is a valid osgVisual config file, check all the root xml node and all of it's children of osgvisualconfiguration for the specified module
    128         xmlNode* tmpNode = checkXMLNodeChildrenForModule(root_element, moduleName);
    129 
    130         if( !tmpNode ) // if no valid node was found: clena up. Otherwise: the caller has to clean up.
     129        xmlNode* tmpNode = checkXMLNodeChildrenForModule(root_element, moduleName, disabled);
     130
     131        if( !tmpNode ) // if no valid node was found or the module is disabled: clean up. Otherwise: the caller has to clean up.
    131132        {
    132133                xmlFreeDoc(doc);        // free the document
     
    139140}
    140141
    141 xmlNode* util::checkXMLNodeChildrenForModule(xmlNode* node, std::string moduleName)
    142 {
    143         for (xmlNode *cur_node = node; cur_node; cur_node = cur_node->next)     // iterate through all elements
     142xmlNode* util::checkXMLNodeChildrenForModule(xmlNode* node, std::string moduleName, bool& disabled)
     143{
     144        for (xmlNode *cur_node = node; cur_node; cur_node = cur_node->next)     // iterate through all XML elements
    144145        {
    145146                // Is the node the one we are searching for?
     
    170171                                        if( attr_name == "enabled" && attr_value == "yes" )
    171172                                        {
    172                                                 OSG_ALWAYS << "Found XML module configuration for " << moduleName << std::endl;
     173                                                OSG_DEBUG << "Found XML module configuration for " << moduleName << std::endl;
    173174                                                return cur_node;
    174175                                        }
    175176                                        if( attr_name == "enabled" && attr_value == "no" )
    176177                                        {
    177                                                 OSG_ALWAYS << "Found XML module configuration for " << moduleName << ", but it is DISABLED." << std::endl;
     178                                                disabled = true;
     179                                                OSG_DEBUG << "Found XML module configuration for " << moduleName << ", but it is DISABLED." << std::endl;
    178180                                                return NULL;
    179181                                        }
     
    183185                        else    // Otherwise: check its children..
    184186                        {
    185                                 xmlNode* tmp_XmlNode = checkXMLNodeChildrenForModule(cur_node->children, moduleName);
     187                                xmlNode* tmp_XmlNode = checkXMLNodeChildrenForModule(cur_node->children, moduleName, disabled);
    186188                                if(tmp_XmlNode)
    187189                                        return tmp_XmlNode;
Note: See TracChangeset for help on using the changeset viewer.