Skip to content

Commit

Permalink
more systematic approach to organising the megamodel examples
Browse files Browse the repository at this point in the history
  • Loading branch information
grammarware committed Oct 11, 2012
1 parent 2e39561 commit 3fce19a
Show file tree
Hide file tree
Showing 14 changed files with 143 additions and 1 deletion.
3 changes: 3 additions & 0 deletions topics/mega/lib/ox/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.back.megal
*.dot
*.pdf
7 changes: 7 additions & 0 deletions topics/mega/lib/ox/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
all:

build:
cp ../../../../../101repo/capabilities/Object_XML_mapping/MegaL/*.megal .

clean:
rm -f *.dot *.pdf
8 changes: 8 additions & 0 deletions topics/mega/lib/ox/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
These megamodels are taken directly from the 101companies repository.
They were available at this address:
https://github.com/101companies/101repo/tree/master/capabilities/Object_XML_mapping/MegaL

For more information on the project, look for:
http://101companies.org/

Re-run 'make build' if you want to refresh the files — requires a cloned copy of the 101companies repository.
14 changes: 14 additions & 0 deletions topics/mega/lib/ox/annotation.megal
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{- Object/XML mapping may be customized by some annotation mechanism such that schema-derived or authored OO types and their members are annotated with hints regarding de-/serialization. -}

megamodel capabilities/Object_XML_mapping/annotation .

include capabilities/Object_XML_mapping/serialization .
include capabilities/Object_XML_mapping/deserialization .

variable Language Annotation partOf OoLanguage .
variable Language OxAnnotation subsetOf Annotation .
variable Fragment+ anno partOf ooTypes .

OxAnnotation partOf OxMapper .
deserialize dependsOn anno .
serialize dependsOn anno .
12 changes: 12 additions & 0 deletions topics/mega/lib/ox/configuration.megal
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{- Configuration of Object/XML mapping may be achieved by designated configuration files. An additional or alternative form of configuration may be achieved by annotations, as discussed elsewhere. -}

megamodel capabilities/Object_XML_mapping/configuration .

include capabilities/Object_XML_mapping/values .

variable Language OxConfiguration .
variable File config elementOf OxConfiguration .

OxConfiguration partOf OxMapper .
deserialize dependsOn config .
serialize dependsOn config .
16 changes: 16 additions & 0 deletions topics/mega/lib/ox/deserialization.megal
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{- This module describes the value-level aspect of specifically de-serialization. (There is a related module for specifically serialization. At the heart of this description is a function deserialize, which is somehow derived by the mapper from the XML types (or the corresponding OO types) such that deserialization may map an XML document to an object graph with the suitable correspondence and conformance relationships. -}

megamodel capabilities/Object_XML_mapping/deserialization .

include capabilities/Object_XML_mapping/values .

local Function deserialize : XML -> ObjectGraphs .
variable File xmlInputDoc elementOf XML .
variable ObjectGraph intialObj elementOf ObjectGraphs .

deserialize dependsOn OxMapper .
deserialize dependsOn xmlTypes .
xmlInputDoc conformsTo xmlTypes .
finalObj conformsTo ooTypes .
finalObj correspondsTo xmlInputDoc .
deserialize(xmlInputDoc) |-> intialObj .
10 changes: 10 additions & 0 deletions topics/mega/lib/ox/generation.megal
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{- Arguably, the typical Object/XML mapping technology comes with a code generation component to derive OO types from XML types. Conceptually, though, this component is optional, which is why it is only introduced now. -}

megamodel capabilities/Object_XML_mapping/generation .

include capabilities/Object_XML_mapping/types .

local Function generator : XmlSchemas -> MappableOo .

generator partOf OxMapper.
generator(xmlTypes) |-> ooTypes .
12 changes: 12 additions & 0 deletions topics/mega/lib/ox/read.megal
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{- De-serialization was already discussed in a designated module, but the derivation of the corresponding function for de-serialization was not yet explained. To this end, we need to assume actual program code which makes use of appropriate library functionality to issue de-serialization. (There is a similar module for serialization.) -}

megamodel capabilities/Object_XML_mapping/read .

include capabilities/Object_XML_mapping/deserialization .

variable File problemProgram elementOf OoLanguage .
variable Fragment deserialization partOf problemProgram .

problemProgram dependsOn ooTypes .
deserialization realizationOf deserialize .
deserialization dependsOn OxLibrary .
16 changes: 16 additions & 0 deletions topics/mega/lib/ox/serialization.megal
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{- This module describes the value-level aspect of specifically serialization. (There is a related module for specifically de-serialization. At the heart of this description is a function serialize, which is somehow derived by the mapper from the XML types (or the corresponding OO types) such that serialization may map an object graph to an XML document with the suitable correspondence and conformance relationships. -}

megamodel capabilities/Object_XML_mapping/serialization .

include capabilities/Object_XML_mapping/values .

local Function serialize : ObjectGraphs -> XML .
variable File xmlOutputDoc elementOf XML .
variable ObjectGraph finalObj elementOf ObjectGraphs .

serialize dependsOn OxMapper .
serialize dependsOn xmlTypes .
xmlOutputDoc conformsTo xmlTypes .
finalObj conformsTo ooTypes .
finalObj correspondsTo xmlOutputDoc .
serialize(finalObj) |-> xmlOutputDoc .
19 changes: 19 additions & 0 deletions topics/mega/lib/ox/technology.megal
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{- This is the basic module explaining the component structure and inter-language and technology dependencies for an Object/XML mapping technology. -}

megamodel capabilities/Object_XML_mapping/technology .

variable Technology OxMapper . -- the name for the technology
variable Library OxLibrary . -- the assumed support library
variable Language XmlSchemas . -- the targeted XML type system, e.g., XSD
variable Language OoLanguage . -- the targeted OO language
variable Language MappableOo . -- the OO subset used in mapping
Language XML . -- XML as serialization format
variable Language ObjectGraphs . -- object graphs in memory

OxLibrary partOf OxMapper .
OxMapper dependsOn XmlSchemas .
OxMapper dependsOn OoLanguage .
MappableOo subsetOf OoLanguage .
MappableOo partOf OxMapper .
OxMapper dependsOn XML .
OxMapper dependsOn ObjectGraphs .
13 changes: 13 additions & 0 deletions topics/mega/lib/ox/types.megal
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{- This module covers the essential type-level aspects of Object/XML mapping. In particular, the types in the spaces XMLware and the objectware are pointed as they correspond to each other. We also make explicit the existence of a problem-specific language underlying the involved type-level artifacts. We think of this language as being abstract in the sense of not fixing it here as being a set of XML trees or object graphs. -}

megamodel capabilities/Object_XML_mapping/types .

include capabilities/Object_XML_mapping/technology .

variable File+ xmlTypes elementOf XmlSchemas .
variable File+ ooTypes elementOf MappableOo .
local Language problemLanguage .

xmlTypes correspondsTo ooTypes .
xmlTypes definitionOf problemLanguage .
ooTypes definitionOf problemLanguage .
12 changes: 12 additions & 0 deletions topics/mega/lib/ox/write.megal
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{- Serialization was already discussed in a designated module, but the derivation of the corresponding function for serialization was not yet explained. To this end, we need to assume actual program code which makes use of appropriate library functionality to issue serialization. (There is a similar module for de-serialization.) -}

megamodel capabilities/Object_XML_mapping/write .

include capabilities/Object_XML_mapping/serialization .

variable File problemProgram elementOf OoLanguage .
variable Fragment serialization partOf problemProgram .

problemProgram dependsOn ooTypes .
serialization realizationOf serialize .
serialization dependsOn OxLibrary .
File renamed without changes.
2 changes: 1 addition & 1 deletion topics/mega/src/MegaParser.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import IO;

public void main(list[str] args)
{
loc base = |cwd:///../tests|;
loc base = |cwd:///../lib/ox|;
for (f <- listEntries(base), endsWith(f,".megal"))
{
println("Getting a parse tree of <f>...");
Expand Down

0 comments on commit 3fce19a

Please sign in to comment.