2015-04-08 02:58:39 +00:00
|
|
|
/*global define*/
|
|
|
|
|
|
|
|
define(
|
|
|
|
['./ContainmentTable'],
|
|
|
|
function (ContainmentTable) {
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Defines composition policy as driven by type metadata.
|
|
|
|
*/
|
2015-04-08 04:03:36 +00:00
|
|
|
function CompositionPolicy($injector) {
|
2015-04-08 02:58:39 +00:00
|
|
|
// We're really just wrapping the containment table and rephrasing
|
|
|
|
// it as a policy decision.
|
2015-04-08 04:03:36 +00:00
|
|
|
var table;
|
|
|
|
|
|
|
|
function getTable() {
|
|
|
|
return (table = table || new ContainmentTable(
|
|
|
|
$injector.get('typeService'),
|
|
|
|
$injector.get('capabilityService')
|
|
|
|
));
|
|
|
|
}
|
2015-04-08 02:58:39 +00:00
|
|
|
|
|
|
|
return {
|
|
|
|
/**
|
|
|
|
* Is the type identified by the candidate allowed to
|
|
|
|
* contain the type described by the context?
|
|
|
|
*/
|
|
|
|
allow: function (candidate, context) {
|
2015-04-08 04:03:36 +00:00
|
|
|
return getTable().canContain(candidate, context);
|
2015-04-08 02:58:39 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
return CompositionPolicy;
|
|
|
|
}
|
|
|
|
);
|