1. Structure of AToM3 Objects
All the objects that are drawn in the canvas (including links!) inherit
from ASGNode. These objects
conatin the semantic information as well as a pointer (graphObject_)
to the graphical appearance, if any. The following picture shows the important
attributes of the ASGNode
class from a user point of view.
Figure 1: Attributes of ASGNode.
Next figure shows the main methods:
graphClass_ : is a pointer to the graphical class associated with this
object. This class must inherit from VisualObj.
graphObject_ : is a pointer to an instance of the graphical class associated
with this object.
in_connections_ : is a list of pointers to the incoming connections.
out_connections_ : is a list of pointers to the outgoing connections.
keyword_ : is a pointer to the attribute which is the object's
keyword. The object's keyword must be specified at the meta-level, and
it must be an ATOM3String.
generatedAttributes : A dictionary which has as keys the name of the attributes
declared at the meta-level and as values a tuple which contains as the
first argument a string with the type's name (an AToM3 type)
and following the necessary type's arguments.
realOrder: A list with the attributes names, ordered in the same way as
the user specified them. This is necessary as when traversing a dictionary
the keys() method returns the keys in arbitrary order.
Figure 2: Methods of ASGNode.
isSubclass : A method which returns 1 if node (an object) is a subclass
of which (the string name of the class).
hasGenerativeAttributes : A method which returns 1 if the entity has generative
0 otherwise. Types will be explained in section
show : Shows the widget associated with each attribute of the object. It
creates a frame with parent as an argument and places the widgets
there. If we are editing a graph grammar (LHS or RHS), it will also show
the widgets to edit the aditional information
toString : returns a string with the concatenation of the result of calling
to toString() on each attribute. If maxWide is specified and the
string is greater than maxWide, then it is cutted to this value, adding
getValue : This method gets the value of the object. Returns a tuple containing
the value of each attribute of the object.
setValue : This method sets the value of the object. It receives a tuple
containing the value of each attribute of the object.
invalid : Returns 1 if the node has some invalid attribute, 0 otherwise.
destroy : Destroys the node, calling destroy() on all its generated
copy : copies the common attributes from the other object into self.
preCondition : a function which is called from AToM3 before an event is
triggered. This function calls the appropriate constraints of the object.
postCondition : a function which is called from AToM3 after an event
is triggered. This function calls the appropriate constraints of the object.
Suposse you are building a meta-model using the Entity-Relationship formalism,
and you have created the following entity:
Figure 3: An example
and associated it a graphical form, and that you have defined the following
POSTCondition (named lessThan1000) on EDIT:
ivalue = self.aNumber.getValue()
which checks that the aNumber attribute has a value lower than 1000. Constraints
will be explained in the following section.
if ivalue >= 1000: return ("The value you entered("+str(ivalue)+")
is too big", self)
Then if you click on Model|Generate code, AToM3 generates
(besides other files) a file called
in the directory for code generation. You can see how the generated class
how two new methods have been added:
Besides, the methods preCondition and postCondition have
been filled in order to call the appropriate constraints. Observe that
graphical constraints are also called at the end of these methods.
clone which creates a new copy of the object.
lessThan1000: which contains the code of the constraint we have just created.
Another important detail is that the attribute parent has been
added in the constructor. This atttribute is a pointer to the ATOM3 class
instance where this object is located.
Maintained by Juan
de Lara. Last modified 22 July 2002.