mirror of
https://github.com/nasa/openmct.git
synced 2025-06-12 20:28:14 +00:00
[Containment] Add general policy for containment rules
Add general policy for supporting containment rules, WTD-962.
This commit is contained in:
29
platform/containment/src/CompositionPolicy.js
Normal file
29
platform/containment/src/CompositionPolicy.js
Normal file
@ -0,0 +1,29 @@
|
||||
/*global define*/
|
||||
|
||||
define(
|
||||
['./ContainmentTable'],
|
||||
function (ContainmentTable) {
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Defines composition policy as driven by type metadata.
|
||||
*/
|
||||
function CompositionPolicy(typeService, capabilityService) {
|
||||
// We're really just wrapping the containment table and rephrasing
|
||||
// it as a policy decision.
|
||||
var table = new ContainmentTable(typeService, capabilityService);
|
||||
|
||||
return {
|
||||
/**
|
||||
* Is the type identified by the candidate allowed to
|
||||
* contain the type described by the context?
|
||||
*/
|
||||
allow: function (candidate, context) {
|
||||
return table.canContain(candidate, context);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return CompositionPolicy;
|
||||
}
|
||||
);
|
Reference in New Issue
Block a user