// DiagnosticsHistory
/**
* @fileOverview a file to define RWTRobotMonitor.DiagnosticsHistory class.
* @author Ryohei Ueda
*/
/**
* @class DiagnosticsHistory
* @param spec
*/
ROSLIB.DiagnosticsHistory = function(spec) {
if (typeof spec === 'undefined') {
spec = {};
}
this.root = new ROSLIB.DiagnosticsDirectory({name: 'root'});
};
/**
* adding a status to the history.
* @param status - instance of DiagnosticsStatus
*/
ROSLIB.DiagnosticsHistory.prototype.registerStatus = function(status) {
// parse paths
// lookup directory to insert into
var parent_dir = this.root;
for (var i = 0; i < status.path.length; i++) {
var the_dir = parent_dir.findDirectory(status.path[i]);
if (the_dir === null) {
the_dir = parent_dir.createChild(status.path[i]);
}
parent_dir = the_dir;
}
// finally, parent_dir should point to the directory
// the status should be inserted into
parent_dir.registerStatus(status);
return parent_dir;
};