Skip to content
Snippets Groups Projects
Select Git revision
  • 77642f158a17991a8c017cc8bc7922b1e75aaf4b
  • main default protected
2 results

context.jl

Christian Gutsche's avatar
Christian Gutsche authored
Big Update! Added Context Rules for Context Petri nets fire conditions. Roles renamed to Mixin, for later update in which Relational Mixins aka Roles are going to be added.
77642f15
History

Context.jl -- A simple Library for Context-Oriented Programming

How to Start

To load the Module, add include("<<location of context.jl file>>") to your script. If your script is located just in this dir, use the following (in Windows): include("./context.jl")

using .context Will then add all the function listed below to the namespace.

With import .context e.g. you have to write context.getRoles().

Some Background Structures

Context An abstract type. Will be super type of concrete context types.

Role An abstract type. Will be super type of concrete role types.

ContextManagement A data base for all contexts and roles that are defined and active.

Available Functions and Macros

@newContext <<Context Name>> Creates a new Type <<Context Name>>ContextType and an Object <<Context Name>> of this type

@newRole <<Role Name>> <<List of Attributes>> <<Context, role lives in>> <<Type, role can be assigned to>> Creates a new Struct <<Role Name>> with the Attributes defined in <<List of Attributes>>

@context <<Context Name>> <<function Definition>> Creates a function, specifically defined for the context <>. Note that, the variable context will be available inside the function by default.

@context <<Context Name>> <<function call>> Calls a function, that was defined via @context <<Context Name>> <<function Definition>>. Note that, the variable context will be available inside the function by default.

assignRole(<<Type>> => <<Role Name>>(<<Role Attributes>>), <<Context Name>>) @context <<Context Name>> assignRole(<<Type>> => <<Role Name>>(<<Role Attributes>>)) Assigns a Role <> to a <> in the context <>

disassignRole(<<Type>> => <<Role Name>>(<<Role Attributes>>), <<Context Name>>) @context <<Context Name>> disassignRole(<<Type>> => <<Role Name>>(<<Role Attributes>>)) Disassigns a Role <> to a <> in the context <>

getContexts() Returns a list of all defined Contexts.

getRoles() Returns a Dict{Context, Dict{Any, Vector{DataType}}} of all defined Roles. E.g.: {<<Context Name 1>> => {<<Class Name 1>> => [<<Role 1>>], <<Class Name 2>> => [<<Role 2>>]}, <<Context Name 2>>=>{<<Class Name 1>> => [<<Role 3>>, <<Role 4>>]}}

getRoles(<<Object Name>>) Returns a Dict{Context, DataType} for a specific object <>.

getRole(<<Object Name>>, <<Context Name>>) Returns the Role, that <> is playing in the context <>.

Example

For an Example, look into contextExample.jl