Skip to main content
Sign in
Snippets Groups Projects
Select Git revision
  • 2a80158eec2acb53a1d973845fdc7fcc6889b1e0
  • main default protected
2 results

context.jl

Christian Gutsche's avatar
Christian Gutsche authored
2a80158e
History
Name Last commit Last update
context.jl
contextExample.jl
readMe.md

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

How to Start

To load the Module, add 'include("<>")' 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 <>' Creates a new Type '<>ContextType' and an Object '<>' of this type

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

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

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

'assignRole(<> => <>(<>), <>)' '@context <> assignRole(<> => <>(<>))' Assigns a Role <> to a <> in the context <>

'disassignRole(<> => <>(<>), <>)' '@context <> disassignRole(<> => <>(<>))' 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(<>) Returns a 'Dict{Context, DataType}' for a specific object <>.

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

Example

For an Example, look into 'contextExample.jl'