using simgear::PropertyList;
using std::string;
-FGDeviceConfigurationMap::FGDeviceConfigurationMap( const string& relative_path)
+FGDeviceConfigurationMap::FGDeviceConfigurationMap( const string& relative_path,
+ SGPropertyNode* nodePath,
+ const std::string& nodeName)
{
+ // scan for over-ride configurations, loaded via joysticks.xml, etc
+ BOOST_FOREACH(SGPropertyNode_ptr preloaded, nodePath->getChildren(nodeName)) {
+ BOOST_FOREACH(SGPropertyNode* nameProp, preloaded->getChildren("name")) {
+ overrideDict[nameProp->getStringValue()] = preloaded;
+ } // of names iteration
+ } // of defined overrides iteration
+
scan_dir( SGPath(globals->get_fg_home(), relative_path));
scan_dir( SGPath(globals->get_fg_root(), relative_path));
}
SGPropertyNode_ptr
FGDeviceConfigurationMap::configurationForDeviceName(const std::string& name)
{
+ NameNodeMap::iterator j = overrideDict.find(name);
+ if (j != overrideDict.end()) {
+ return j->second;
+ }
+
+// no override, check out list of config files
NamePathMap::iterator it = namePathMap.find(name);
if (it == namePathMap.end()) {
return SGPropertyNode_ptr();
try {
readProperties(it->second.str(), result);
result->setStringValue("source", it->second.c_str());
- } catch (sg_exception& e) {
+ } catch (sg_exception&) {
SG_LOG(SG_INPUT, SG_WARN, "parse failure reading:" << it->second);
return NULL;
}
bool FGDeviceConfigurationMap::hasConfiguration(const std::string& name) const
{
+ NameNodeMap::const_iterator j = overrideDict.find(name);
+ if (j != overrideDict.end()) {
+ return true;
+ }
+
return namePathMap.find(name) != namePathMap.end();
}
if (!path.exists())
return;
+ flightgear::NavDataCache* cache = flightgear::NavDataCache::instance();
+ flightgear::NavDataCache::Transaction txn(cache);
+
simgear::Dir dir(path);
simgear::PathList children = dir.children(simgear::Dir::TYPE_FILE |
simgear::Dir::TYPE_DIR | simgear::Dir::NO_DOT_OR_DOTDOT);
- flightgear::NavDataCache* cache = flightgear::NavDataCache::instance();
BOOST_FOREACH(SGPath path, children) {
if (path.isDir()) {
} // of cached file stamp is valid
} // of child is a file with '.xml' extension
} // of directory children iteration
+
+ txn.commit();
}
void FGDeviceConfigurationMap::readCachedData(const SGPath& path)
SGPropertyNode_ptr n(new SGPropertyNode);
try {
readProperties(path.str(), n);
- } catch (sg_exception& e) {
+ } catch (sg_exception&) {
SG_LOG(SG_INPUT, SG_WARN, "parse failure reading:" << path);
return;
}