1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # Copyright 2012 Jean Privat <jean@pryen.org>
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 # The abstract concept of model and related common things
20 # The container class of a Nit object-oriented model.
21 # A model knows modules, classes and properties and can retrieve them.
25 # A named and possibly documented entity in the model.
26 # This class is usefull to generalize presentation of entities to the human.
27 abstract class MEntity
28 # The short (unqualified) name of this model entity
29 fun name
: String is abstract
32 # Something that represents a concern
33 abstract class MConcern
35 # The concern that contains `self` or null if `self` is the root of the concern hierarchy
36 fun parent_concern
: nullable MConcern is abstract
39 # A visibility (for modules, class and properties)
40 # Valid visibility are:
42 # * `intrude_visibility`
43 # * `public_visibility`
44 # * `protected_visibility`
47 # Note this class is basically an enum.
48 # FIXME: use a real enum once user-defined enums are available
51 redef type OTHER: MVisibility
53 redef var to_s
: String
55 private var level
: Int
57 private init(s
: String, level
: Int)
63 # Is self give less visibility than other
64 # none < private < protected < public < intrude
67 return self.level
< other
.level
71 fun intrude_visibility
: MVisibility do return once
new MVisibility("intrude", 5)
72 fun public_visibility
: MVisibility do return once
new MVisibility("public", 4)
73 fun protected_visibility
: MVisibility do return once
new MVisibility("protected", 3)
74 fun private_visibility
: MVisibility do return once
new MVisibility("private", 2)
75 fun none_visibility
: MVisibility do return once
new MVisibility("none", 1)