Generating a Generator Jeff Gray University of Alabama at Birmingham Department of Computer and Info - PowerPoint PPT Presentation

1 / 15
About This Presentation
Title:

Generating a Generator Jeff Gray University of Alabama at Birmingham Department of Computer and Info

Description:

nodeType XMLParser::findModel(nodeType aNode, CComBSTR name) ... CComPtr IXMLDOMNode attr = XMLParser::findAttribute (aNode, 'id'); XMLParser::getStr(attr, res) ... – PowerPoint PPT presentation

Number of Views:59
Avg rating:3.0/5.0
Slides: 16
Provided by: jeff92
Category:

less

Transcript and Presenter's Notes

Title: Generating a Generator Jeff Gray University of Alabama at Birmingham Department of Computer and Info


1
Generating a GeneratorJeff GrayUniversity of
Alabama at BirminghamDepartment of Computer and
Information Sciencesgray (at) cis.uab.eduhttp//
www.gray-area.org
  • GPCE Young Researchers Workshop
  • October 5, 2002
  • Pittsburgh, PA

This work is supported by the DARPA IXO, under
the Program Composition for Embedded Systems
(PCES) program,
2
Background
  • Aspect-Oriented Domain Modeling

3
Model-Integrated Computing (MIC) with theGeneric
Modeling Environment (GME)
Meta-modeling Environment
Domain-specific Modeling Environment
4
Difficulties in Managing Constraints in Models
Multiple Levels of Hierarchy
Change Maintenance???
A
4
Replicated Structures
3
B
F
1
2
c
d
e
3'
B
B
4
1''
2''
1'
2'
c
d
e
c
d
e
Context Sensitive
5
Domain-Specific Strategies
strategy ApplyConstraint(constraintName string,
expression string) addAtom("OCLConstraint",
"Constraint", constraintName).addAttribute("Expres
sion", expression)   strategy
RemoveConstraint(constraintName string)
findAtom(constraintName).removeChild()   strate
gy ReplaceConstraint(constraintName string,
expression string) RemoveConstraint(constrai
ntName) ApplyConstraint(constraintName,
expression)
6
The Metaweaver Framework
Specification Aspects
XML Parser
Strategies (C)
Aspect Parser
XML (Model Hierarchy)
Strategies
Strategy Code Generator
strategy ApplyConstraint(constraintName string,
expression string) addAtom("OCLConstraint",
"Constraint", constraintName).addAttribute("Expres
sion", expression)   strategy
RemoveConstraint(constraintName string)
findAtom(constraintName).removeChild()   strate
gy ReplaceConstraint(constraintName string,
expression string) RemoveConstraint(constrai
ntName) ApplyConstraint(constraintName,
expression)
7
Extending the Framework
  • Previous implementation (strength)
  • Provides variability, through domain-specific
    strategies, among different modeling domains in
    the GME (tool specific)
  • Future implementation (address weakness)
  • Provide variability such that new weavers can be
    instantiated to support other tools (e.g., Rose)
  • Provide variability to support different aspect
    modeling languages other than ECL (not covered
    in this talk)

8
Subset of GME DTD
lt!ELEMENT model (name, (constraintattributemodel
atomreferenceset connection))gt lt!ATTLIST
model id ID IMPLIED kind
NMTOKEN REQUIRED role NMTOKEN IMPLIEDgt lt!EL
EMENT atom (name, (regnodeconstraintattribute))
gt lt!ATTLIST atom id ID IMPLIED kind NMTOKE
N REQUIRED role NMTOKEN IMPLIEDgt lt!ELEMENT
attribute (value, regnode)gt lt!ATTLIST
attribute kind NMTOKEN REQUIREDgt
9
Subset of XMLParser Methods
Implementation details associated with using
underlying MSXML Tool-specific details tied to GME
nodeType XMLParseraddAtom(nodeType self,
CComBSTR kind, CComBSTR role, CComBSTR name)
return addNode(self, "atom", kind, role,
name) nodeType XMLParserfindModel(nodeType
aNode, CComBSTR name) CComBSTR
bstrFind(L"./modelname\"") bstrFind.Append(name
) bstrFind.Append("\"") return
submitXPath(aNode, bstrFind) CComBSTR
XMLParserid(nodeType aNode) CComBSTR
res CComPtrltIXMLDOMNodegt attr
XMLParserfindAttribute (aNode, "id")
XMLParsergetStr(attr, res) return res
10
Variability with Respect to Modeling
ToolsGenerating the XML Parser
Aspect
XML
Strategies (C)
Parser
Parser
Specification Aspects
lt!ELEMENT model (name, (constraintattributemodel
atomreferenceset connection))gt lt!ATTLIST
model id ID IMPLIED kind
NMTOKEN REQUIRED role NMTOKEN IMPLIEDgt lt!ELE
MENT atom (name, (regnodeconstraintattribute))gt
lt!ATTLIST atom id ID IMPLIED kind NMTOKEN
REQUIRED role NMTOKEN IMPLIEDgt lt!ELEMENT
attribute (value, regnode)gt lt!ATTLIST
attribute kind NMTOKEN REQUIREDgt
XML DTD (tool-specific)
11
Code Generator for findModel(within StratGen)
void GeneratorGenerateFindModel() static
findModelCounter 0 genOut ltlt indentStr ltlt
"nodeType aModelFind" ltlt findModelCounter ltlt

" XMLParserfindModel(" ltlt lastVariable
ltlt ", " lastVariable.Format("sd",
"aModelFind", findModelCounter)
12
Variability with Respect to Modeling
ToolsGenerating Portions of StratGen
Meta-Generator
lt!ELEMENT model (name, (constraintattributemodel
atomreferenceset connection))gt lt!ATTLIST
model id ID IMPLIED kind
NMTOKEN REQUIRED role NMTOKEN IMPLIEDgt lt!ELE
MENT atom (name, (regnodeconstraintattribute))gt
lt!ATTLIST atom id ID IMPLIED kind NMTOKEN
REQUIRED role NMTOKEN IMPLIEDgt lt!ELEMENT
attribute (value, regnode)gt lt!ATTLIST
attribute kind NMTOKEN REQUIREDgt
Strategy Code Generator
XML DTD (tool-specific)
13
Conclusion
  • There are three possible degrees of variability
    with the metaweaver framework
  • Variability with respect to modeling
    domains(previous focus)
  • Variability with respect to modeling
    tools(future focus topic of this position
    paper)
  • Variability with respect to aspect modeling
    languages (future focus not covered here)
  • Providing variability among modeling tools can be
    provided by generating a StratGen generator that
    is specific to a particular modeling tool

14
Process of Using a Weaver
15
Code Generation Example
CComPtrltIXMLDOMNodeListgt models0
XMLParsermodels(components, "")
nodeTypeVector selectVec1 XMLParserConvertDomL
ist(models0) nodeTypeVector selectVecTrue1
new stdvectorltnodeTypegt vectorltnodeTypegtit
erator itrSelect1 for(itrSelect1
selectVec1-gtbegin() itrSelect1 !
selectVec1-gtend() itrSelect1)
nodeType selectNode1 (itrSelect1)
nodeType c c selectNode1 CComBSTR
id0 XMLParserid(c) ClData
varforward1(id0) ClData varforward2(referred
ID) bool varforward3 varforward1
varforward2 if(varforward3)
selectVecTrue1-gtpush_back(itrSelect1)
vectorltnodeTypegtiterator itrCollCall1
for(itrCollCall1 selectVecTrue1-gtbegin()
itrCollCall1 ! selectVecTrue1-gtend()
itrCollCall1) eagerLazyapply()
Write a Comment
User Comments (0)
About PowerShow.com