1 /*global $k*/
  2 
  3 /**
  4  * @class Represents a type
  5  * @extends $k.SemanticElement
  6 **/
  7 $k.Type = function() { };
  8 
  9 /**
 10  * Add a supertype
 11  *
 12  * @function
 13  * @param type Type or internal name
 14  * @throws {$k.exception.TypeError} If the argument is not a valid supertype
 15  * @throws {$k.exception.SchemaError} If the argument cannot be added as supertype
 16  * @throws {$k.exception.AccessDenied} If adding the type is not allowed
 17  * @throws {$k.exception.TransactionError} If no write transaction is active
 18 **/
 19 $k.Type.prototype.addSupertype = function(type) { };
 20 
 21 /**
 22  * Returns all subtypes
 23  *
 24  * @function
 25  * @returns {$k.Type[]}
 26 **/
 27 $k.Type.prototype.allSubtypes = function() { };
 28 
 29 /**
 30  * Returns all supertypes
 31  *
 32  * @function
 33  * @returns {$k.Type[]}
 34 **/
 35 $k.Type.prototype.allSupertypes = function() { };
 36 
 37 /**
 38  * Returns true if instances of this type can be created as extensions of instances.
 39  * Only either canCreateExtensions() or canCreateInstances() can be true.
 40  * isAbstract() is true if neither canCreateExtensions() nor canCreateInstances() is true.
 41  *
 42  * @function
 43  * @returns {boolean}
 44  * @see $k.Instance#createExtension
 45  * @see $k.Type#canCreateInstances
 46  * @see $k.Type#isAbstract
 47 **/
 48 $k.Type.prototype.canCreateExtensions = function() { };
 49 
 50 /**
 51  * Returns true if instances / properties of this type can be created.
 52  * Only either canCreateExtensions() or canCreateInstances() can be true.
 53  * isAbstract() is true if neither canCreateExtensions() nor canCreateInstances() is true.
 54  *
 55  * @function
 56  * @returns {boolean}
 57  * @see $k.Type#canCreateExtensions
 58  * @see $k.Type#isAbstract
 59 **/
 60 $k.Type.prototype.canCreateInstances = function() { };
 61 
 62 /**
 63  * Returns the domain of the instances of this type
 64  *
 65  * @function
 66  * @returns {$k.Domain}
 67 **/
 68 $k.Type.prototype.domain = function() { };
 69 
 70 /**
 71  * Returns the estimated number of instances of this type
 72  *
 73  * @function
 74  * @returns {number}
 75 **/
 76 $k.Type.prototype.estimatedNumberOfInstances = function() { };
 77 
 78 /**
 79  * Returns the value of the counter associated with this type.
 80  *
 81  * @function
 82  * @returns {number}
 83 **/
 84 $k.Type.prototype.getCounter = function() { };
 85 
 86 /**
 87  * Increases and returns the value of the counter associated with this type. The counter can be increased concurrently.
 88  *
 89  * @function
 90  * @returns {number}
 91 **/
 92 $k.Type.prototype.increaseCounter = function() { };
 93 
 94 /**
 95  * Returns the internal name
 96  *
 97  * @function
 98  * @returns {string}
 99 **/
100 $k.Type.prototype.internalName = function() { };
101 
102 /**
103  * Returns true if this is an abstract type (cannot create properties/instances/extensions).
104  * isAbstract() is true if neither canCreateExtensions() nor canCreateInstances() is true.
105  *
106  * @function
107  * @returns {boolean}
108 **/
109 $k.Type.prototype.isAbstract = function() { };
110 
111 /**
112  * Returns true if this is equal to or a direct or indirect type of the other type
113  *
114  * @function
115  * @param type Type or internal name
116  * @returns {boolean}
117  * @throws {$k.exception.TypeError} If the argument is not a type
118  * @throws {$k.exception.SchemaError} If the argument is an unknown internal name
119 **/
120 $k.Type.prototype.isKindOf = function(type) { };
121 
122 /**
123  * Returns the exact number of instances of this type
124  *
125  * @function
126  * @returns {number}
127 **/
128 $k.Type.prototype.numberOfInstances = function() { };
129 
130 /**
131  * Remove a supertype
132  *
133  * @function
134  * @throws {$k.exception.TypeError} If the argument is not a valid supertype
135  * @throws {$k.exception.AccessDenied} If removing the type is not allowed
136  * @throws {$k.exception.TransactionError} If no write transaction is active
137 **/
138 $k.Type.prototype.removeSupertype = function(supertype) { };
139 
140 /**
141  * Set to true if it should be possible to extend other instances with instances of this tyoe.
142  * The flag cannot be set to false if extensions exist.
143  * Only either canCreateExtensions() or canCreateInstances() can be true.
144  *
145  * @function
146  * @param {boolean} canCreate
147  * @throws {$k.exception.SchemaError} If it is not possible to change the schema, e.g. when the type already allows to create instances
148  * @see $k.Type#canCreateExtensions
149  * @see $k.Type#setCanCreateInstances
150 **/
151 $k.Type.prototype.setCanCreateExtensions = function(canCreate) { };
152 
153 /**
154  * Set to true if it should be possible to create instances / properties this type.
155  * The flag cannot be set to false if instances exist.
156  * Only either canCreateExtensions() or canCreateInstances() can be true.
157  *
158  * @function
159  * @param {boolean} canCreate
160  * @throws {$k.exception.SchemaError} If it is not possible to change the schema, e.g. when the type already allows to create extensions
161  * @see $k.Type#canCreateInstances
162  * @see $k.Type#setCanCreateExtensions
163 **/
164 $k.Type.prototype.setCanCreateInstances = function(canCreate) { };
165 
166 /**
167  * Set the initial value of the counter associated with this type. Note: this cannot be done concurrently. Use increaseCounter() instead.
168  *
169  * @function
170  * @param {number} counterValue Must be an integer
171  * @returns {number} The counter value
172  * @see $k.Type#increaseCounter
173 **/
174 $k.Type.prototype.setCounter = function(counterValue) { };
175 
176 /**
177  * Sets the internal name, or removes the internal name if null is passed
178  *
179  * @function
180  * @param name New internal name or null
181  * @throws {$k.exception.TypeError} If the argument is not a valid internal name
182  * @throws {$k.exception.AccessDenied} If modifying the type is not allowed
183  * @throws {$k.exception.NotUnique} If the internal name is not unique
184  * @throws {$k.exception.TransactionError} If no write transaction is active
185 **/
186 $k.Type.prototype.setInternalName = function(name) { };
187 
188 /**
189  * Returns the direct subtypes
190  *
191  * @function
192  * @returns {$k.Type[]}
193 **/
194 $k.Type.prototype.subtypes = function() { };
195 
196 /**
197  * Returns the direct supertypes
198  *
199  * @function
200  * @returns {$k.Type[]}
201 **/
202 $k.Type.prototype.supertypes = function() { };
203 
204 /**
205  * Returns the domain that represents this type and its subtype
206  *
207  * @function
208  * @returns {$k.Domain}
209 **/
210 $k.Type.prototype.typeDomain = function() { };
211 
212