mirror of
https://github.com/nasa/openmct.git
synced 2024-12-19 21:27:52 +00:00
[API] More Objects doc
This commit is contained in:
parent
1abcb248fe
commit
a20e8d69b5
@ -19,6 +19,7 @@ define([
|
||||
* Utilities for loading, saving, and manipulating domain objects.
|
||||
* @interface ObjectAPI
|
||||
* @memberof module:openmct
|
||||
* @implements {module:openmct.ObjectProvider}
|
||||
*/
|
||||
var Objects = {},
|
||||
ROOT_REGISTRY = [],
|
||||
@ -49,10 +50,61 @@ define([
|
||||
return PROVIDER_REGISTRY[key.namespace] || FALLBACK_PROVIDER;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a new object provider for a particular namespace.
|
||||
*
|
||||
* @param {string} namespace the namespace for which to provide objects
|
||||
* @param {module:openmct.ObjectProvider} provider the provider which
|
||||
* will handle loading domain objects from this namespace
|
||||
* @memberof {module:openmct.ObjectAPI#}
|
||||
* @name addProvider
|
||||
*/
|
||||
Objects.addProvider = function (namespace, provider) {
|
||||
PROVIDER_REGISTRY[namespace] = provider;
|
||||
};
|
||||
|
||||
/**
|
||||
* Provides the ability to read, write, and delete domain objects.
|
||||
*
|
||||
* When registering a new object provider, all methods on this interface
|
||||
* are optional.
|
||||
*
|
||||
* @interface ObjectProvider
|
||||
* @memberof module:openmct
|
||||
*/
|
||||
|
||||
/**
|
||||
* Save this domain object in its current state.
|
||||
*
|
||||
* @method save
|
||||
* @memberof module:openmct.ObjectProvider#
|
||||
* @param {module:openmct.DomainObject} domainObject the domain object to
|
||||
* save
|
||||
* @returns {Promise} a promise which will resolve when the domain object
|
||||
* has been saved, or be rejected if it cannot be saved
|
||||
*/
|
||||
|
||||
/**
|
||||
* Delete this domain object.
|
||||
*
|
||||
* @method delete
|
||||
* @memberof module:openmct.ObjectProvider#
|
||||
* @param {module:openmct.DomainObject} domainObject the domain object to
|
||||
* delete
|
||||
* @returns {Promise} a promise which will resolve when the domain object
|
||||
* has been deleted, or be rejected if it cannot be deleted
|
||||
*/
|
||||
|
||||
/**
|
||||
* Get a domain object.
|
||||
*
|
||||
* @method get
|
||||
* @memberof module:openmct.ObjectProvider#
|
||||
* @param {string} key the key for the domain object to load
|
||||
* @returns {Promise} a promise which will resolve when the domain object
|
||||
* has been saved, or be rejected if it cannot be saved
|
||||
*/
|
||||
|
||||
[
|
||||
'save',
|
||||
'delete',
|
||||
@ -74,10 +126,24 @@ define([
|
||||
};
|
||||
});
|
||||
|
||||
/**
|
||||
* Add a root-level object.
|
||||
* @param {module:openmct.Identifier} the identifier of the root-level
|
||||
* object to add.
|
||||
* @method addRoot
|
||||
* @memberof module:openmct.ObjectAPI#
|
||||
*/
|
||||
Objects.addRoot = function (key) {
|
||||
ROOT_REGISTRY.unshift(key);
|
||||
};
|
||||
|
||||
/**
|
||||
* Remove a root-level object.
|
||||
* @param {module:openmct.Identifier} the identifier of the root-level
|
||||
* object to remove.
|
||||
* @method removeRoot
|
||||
* @memberof module:openmct.ObjectAPI#
|
||||
*/
|
||||
Objects.removeRoot = function (key) {
|
||||
ROOT_REGISTRY = ROOT_REGISTRY.filter(function (k) {
|
||||
return (
|
||||
@ -91,5 +157,16 @@ define([
|
||||
return new MutableObject(eventEmitter, object);
|
||||
};
|
||||
|
||||
/**
|
||||
* Uniquely identifies a domain object.
|
||||
*
|
||||
* @typedef Identifier
|
||||
* @memberof module:openmct
|
||||
* @property {string} namespace the namespace to/from which this domain
|
||||
* object should be loaded/stored.
|
||||
* @property {string} key a unique identifier for the domain object
|
||||
* within that namespace
|
||||
*/
|
||||
|
||||
return Objects;
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user