41#include "FGModelLoader.h"
42#include "FGXMLFileRead.h"
43#include "models/FGModel.h"
44#include "input_output/FGLog.h"
54Element_ptr FGModelLoader::Open(Element *el)
56 Element_ptr document = el;
57 string fname = el->GetAttributeValue(
"file");
60 FGXMLFileRead XMLFileRead;
61 SGPath path(SGPath::fromUtf8(fname.c_str()));
63 if (path.isRelative())
64 path = model->FindFullPathName(path);
66 if (CachedFiles.find(path.utf8Str()) != CachedFiles.end())
67 document = CachedFiles[path.utf8Str()];
69 document = XMLFileRead.LoadXMLDocument(path);
71 FGXMLLogging log(el, LogLevel::ERROR);
72 log <<
"Could not open file: " << fname << endl;
75 CachedFiles[path.utf8Str()] = document;
78 if (document->GetName() != el->GetName()) {
79 document->SetParent(el);
80 el->AddChildElement(document);
89SGPath CheckPathName(
const SGPath& path,
const SGPath& filename) {
90 SGPath fullName = path/filename.utf8Str();
92 if (fullName.extension() !=
"xml")
93 fullName.concat(
".xml");
95 return fullName.exists() ? fullName : SGPath();
Main namespace for the JSBSim Flight Dynamics Model.