Home
Think v4 (a.k.a. Nuptse) Programmer`s Manual
Contents
1. The definition above of here is foo is equivalent to component here is foo provides itfTypeA as itfa provides itfTypeB as itfb requires itfTypeC as itfc contains subCompX sumCompX contains subCompY subCompDefY binds this itfa to subCompX itfa binds this itfb to subCompY itfb binds subCompY itfc to this itfc binds subCompY itfa to subCompX itfa 2 3 2 2 provides Usage Declares a provided a k a server interface in a component definition provides lt itfType DotName gt as lt itfName Name gt Description Declares a provided a k a server interface named it fName of inter face type it fType Example The following code declares in a component definition here is bar a provided interface named foo of interface type here is Foo interface here is Foo void fool int a int b int foo2 char x component here is bar provides foo as here is Foo 2 3 2 3 requires Usage Declares a required a k a client interface in a component definition requires lt itfType DotName gt as lt itfName Name gt mandatory optional Description Declares a required a k a client interface named it Name of interface type it fType A client interface may be declared as optional or mandatory default is mandatory Any mandatory interface of a component instance must be bound to a server interface The build chain will complain about unbound mandato
2. PrivateData aVar int aVar ServerMethod foo bar int bar int x aVar aVar x x The following example illustrates the use of the annotation where the name of the variable is omitted PrivateData int aVar Si ServerMethod foo bar int bar int x aVar aVar x 23 Predefined annotation Variable names PRIVATE is considered as a private variable That is Nuptse predefines the following annotation PrivateData PRIVATE 2 4 2 11 PrivateMethod Usage Specifies a C function as a private method PrivateMethod lt functionName gt Description Specifies that the C function functionName is a private method A private method is a function that can access data of the component instance access attributes call client methods like a server method but does not implement any method of a server interface If parameter funct ionName is omitted then the anno tation indicates that the function declaration that follows is a private method Examples In the following example the programmer specifies that function prvMeth is a private method which makes a call to a client method gnat ClientMethod gnut gnat gnat PrivateMethod prvMeth int prvMethod int x gnat x x ServerMethod foo bar int bar int x prvMethod x 2 The following
3. bar lt barId gt where foold and barld are the identifiers of respectively the foo and bar client interfaces ETA_CLT_ITE_SET Runtime function to set the server interface identifier corre sponding to a given client interface identifier void META _CLT ITF SET any cltItfId any srvItfId ETA_CLT_ITF_GET Runtime function to get the server interface identifier corre sponding to a given client interface identifier any META CLTITE GET any cltItfId 3 2 2 Server Interfaces Meta Data ME Bi A_NB_SRV_ITFS Compile time value representing the number of server inter faces of the component A_SRVITF_TABLE Variable name that declares a table containing the name and the id of each provided interface This table must be declared as an array of any type which size must be at least the number of server interfaces The type if the table is transformed into a array of struct with two fields 29 e itfName the name if the interface e itfId the id of the interface The table is initialized with values known at compile time For example if a component provides two interfaces foo and bar then the following declared variable any META _SRVITF_TABLE META_NB_SRV_ITFS is transformed into the following code struct char itfName any itfld META SRVITF TABLE META NB SRV ITFS foo lt foold gt bar
4. lt barId gt where foold and barld are the identifiers of respectively the foo and bar server interfaces 3 2 3 Attributes Meta Data ME Py A_NB_ATTS Compile time value representing the number of client interfaces of the component A_ATT_SET Runtime function to set the value of an attribute given its identifier void META ATT SET any attId any attValue ETA_ATT_GET Runtime function to get the value of an attribute given its identifier any META ATT GET any attId 3 2 4 Components Meta Data ME A_NB_SUB_COMPS Compile time value representing the number of sub components of the component A_SUBCOMP_TABLE Variable name that declares a table containing the name and the id of each sub component This table must be declared as an array of any type which size must be at least the number of sub components The type if the table is transformed into a array of struct with two fields e CompName the name of the sub component 30 e compld the id of the sub component The table is initialized with values known at compile time For example if a com ponent contains two sub components foo and bar then the following declared variable any META SUBCOMP TABLE META _NB_SUB_COMPS is transformed into the following code struct char x compName any compld META SUBCOMP TABLE META NB SUB_COMPS foo lt fool
5. attached to a content file content lt propName gt lt propValue gt attached to an implementation part implementation lt propName gt lt propValue gt 3 3 1 Existing properties Some properties are already defined and taken into account by the default builders of the Think compiler These properties are listed bellow with the default value binds static true false Specifies that the binding will not change at runtime Default value is false binds inline true false Specifies that in case the binding is static the compiler should try to inline the code that implement the server interface into the code of the caller of the client interface or generate inline directives so as to inform the C compiler to inline the code attribute const true false Specifies that the attribute will not change at runtime Default value is false provides single true false Specifies that in the scope of the in terface this entry point will be the only one for the corresponding interface type De fault value is false implementation shared true false Specifies that the code of the implementation part should be shared between component instances if possibld Default value is true attribute lt value gt Can be attached to component attribute provides requires or implementation to add __attribute__ lt value gt to glue descriptors of respectively components attributes server inte
6. a component type in the Fractal sense since it also expresses how a component type is implemented Also we may sometimes say that a component definition contains sub components but actually only components that is component instances can contain sub components To be precise a component definition may contains declarations of references to sub components At runtime instances of this component definition will contain references to sub components This is very similar to a Java class that contains a declaration of a typed reference at runtime objects 1 e instances of this class will contain references to other objects 2 2 The Interface Description Language IDL Think provides a language called an Interface Description Language IDL to de clare interface types In the Nuptse version this language extends the C grammar with few keywords In brief an interface type is defined by a set of methods and a set of constants Methods are declared as C functions and constants are declared as typed variable with an initial value An interface is declared as follows package lt packageName DotName gt typedefs lt filePath DotName gt x interface lt interfaceTypeName Name gt lt methodDeclaration gt lt constantDeclaration gt x packageName is the name of the package that contains this interface type Like in Java it must corresponds to the path of the directory that contains the file into which t
7. f4 c contains code for the implementation part imp2 and file rep1 a b d 4 c is to be added as if Note that rep2 a b c f2 c will be ignored component here is foo content a b fl content a b c f2 for impl content a b f3 for impl content a b c f4 for imp2 content a b d f5 raw File structure repl a b fl c c f2 c rep2 a b fB c c See section 3 1 for explainations on multiple implementation parts 14 f2 c d f5 c 2 3 3 Deprecated Keywords and constructions The following keywords and constructions are still supported by the compiler but are deprecated and may not be supported in future releases of the compiler Programmers are strongly invited to use the corresponding keyword or construction deprecated new expression composite component primitive component type abstract component attributes attribute attribute attribute lt attName gt lt attType gt lt attType gt lt attName gt skeleton content nolcd provides fractal api LifeCycleController implements extends There is no more dinstcintion between primitive and composite components Components are hybrid components in the sense that they can contain implementation code and sub components b nolcc means the absence of the keyword 2 4 The NuptC Component Programming Language 2 4 1 Introduction Nuptse prov
8. interfaces of the component Note that if two provided interfaces have methods with the same name an error will 17 be thrown if this annotation is used for both interfaces In that case the standard an notation ServerMethod must be used for at least one of the conflicting interfaces This is a shortcut to writing the following annotation for each method methodName of each interface it Name provided by the component x ServerMethod lt itfName gt lt methodName gt lt methodName gt Example In the following example the programmer specifies that methods bar and gnu of interface foo are implemented by C functions with identical names DefaultServerMethods foo int bar int x al void gnu short x 2 4 2 3 ServerInterfacePrefix Usage Specifies the prefix of functions that implement the methods of a server inter face x ServerInterfacePrefix lt serverInterfaceName gt lt prefix gt 00 Description Specifies that the methods of a provided interface serverInterfaceNam will be implemented by C functions having the same name than the methods prefixed with prefix This is a shortcut to writing the following annotation for each method methodName of each interface it Name provided by the component x ServerMethod lt itfName gt lt methodName gt lt prefix gt lt methodName gt QQ x Examples In the following example
9. the programmer specifies that the method bar and gnu of server interface foo are implemented respectively by C functions my_bar and my_gnu ServerInterfacePrefix foo my AA int my bar int x 18 feck void my_gnu short x 2 4 2 4 ClientMethod Usage Specifies the symbol representing a client method x ClientMethod lt clientInterfaceName gt lt methodName gt lt functionName gt Description Specifies that the C function symbol functionName represents the method methodName of the client interface clientInterfaceName Calls to the client method can then be made by a C call using this symbol Note that the methodName parameter refers to the IDL definition of the type of the interface whereas the serverInterfaceName refers to the name of the interface required by the im plemented component found in the corresponding ADL file Also note that client methods can only be called from server or private methods Trying to call the method in a normal C function will raise an error Example In the following example the programmer specifies that the C function sym bol myBar represents the method bar of the client interface foo This method is called in function aMet hod ClientMethod foo bar myBar int aMethod int x myBar x Predefined annotations For each method methodName of each interface it Name required by the component Nuptse predefines t
10. typedef struct int x aType 2 3 The Architecture Description Language ADL 2 3 1 Introduction 2 3 2 Keywords 2 3 2 1 component Usage Declares a component definition abstract component lt compDefName DotName gt extends lt extCompDefName DotName gt Description Declares a component definition named compDefName This defini tion may extend another definition named ext CompDefName Extending a compo nent definition is like inlining the whole content of the extended definition into the extending one Abstract component definition are component definition that are not sufficiently defined or that are not fully functional to exist at runtime That is they can only be used to declare an abstract sub component in a component definition see 2 3 2 6 for more details Also an component that contains an abstract sub component must be declared abstract Example The following code declares an abstract component definition named here and another concrete component definition named here is foo as an extension of here is bar ziS barn abstract component here is bar provides itfTypeA as itfa contains subCompX subCompDefX binds this itfa to subCompX itfa component here is foo extends here is bar provides itfTypeB as itfb requires itfTypeC as itfc contains subCompY subCompDefY binds this itfb to subCompY itfb binds subCompY itfc to this itfc binds subCompY itfa to subCompX itfa
11. 0 PrivateDatal 23 2 4 2 11 PrivateMethod 24 ee oh Satta se cet heey de ee Rd on 25 De 4 ob a eA Se de 25 3 Advanced Programming 27 3 1 Implementation PartS 27 a E a ae A Se 8 28 3 2 1 Client Interfaces Meta Datal 28 3 2 2 Server Interfaces Meta Data 29 3 2 3 Attributes Meta Datal 30 dire Gi Ss id 30 ee Aa a dd dd 31 3 3 1 Existing properties 32 33 Pride lies dent pere 33 PANNE RARES 34 eh eed ot eed 35 3 8 Entering component world 35 Chapter 1 Introduction This document aims to give sufficient information to help developers design and pro gram Think components ar applications made of existing Think components It does not intend to detail how to use the Think compiler in order to build a component based software from existing component definitions Such information can be found in the Think User s Manual Think is a native implementation of the Fractal component model It can be used to develop OS kernels though it is not resticted to this application domain the framework can be used to develop any component based system or application writ ten in C Thanks to the Fractal Component Model Think adopts a clear separation between architecture and components As a consequence Think accelerates native software de
12. Think v4 a k a Nuptse Programmer s Manual July 1 2008 Revision History revison date description author 1 0 XXX initial version Olivier Lobry Orange Labs Contents 4 2 Basic programming 6 2 1 Basic CONCepts ese bie eee wre PRE e a 6 2 2 The Interface Description Language IDL 7 2 3 The Architecture Description Language ADL 9 2 3 1 Introduction 9 i eet Gs ot a fe res eet ee ek 9 2 3 2 1 component 9 Rare DR Ae ts hey a ee it 10 2 3 2 3 TEGUITES i s s rai ee idees 10 2 3 2 4 attribute 11 23 23 ASSIPNS e a a o a she 11 2 952 0 CONTAINS 34 ic bia dd dr 12 2 327 Singleton s 62 2 455 ov ebb BES is 13 2 3 2 8 content 13 nee 15 ie 15 2 4 1 Introduction 15 Sie Goce ea ts fee ee evga tances tes 16 2 4 2 1 ServerMethod 16 2 4 2 2 DefaultServerMethods 17 2 4 2 3 ServerInterfacePrefix 18 2 4 2 4 ClientMethod 19 2 4 2 5 DefaultClientMethods 20 2 4 2 6 ClientInterfacePrefix 20 2 4 2 7 Attributel 21 2 4 2 8 DefaultAttributes 22 2 4 2 9 AttributesPrefiX 22 2 4 2 1
13. al concepts For ex ample to implement a method foo of a server interface bar one had to declare a C function named SRV_foo__ bar with appropriate parameters While this approach simplified a lot the burden of programming component compared to the previous ver sions and did allow arbitrary optimizations and implementations of architectural con cepts we went one step further annotations CodeGen is now able to parse annotations in C comments delimited by two tokens like ServerMethod foo bar bar Qe x It does not de fine a particular syntax of the annotations It just detects them and notifies them through a Java ParsingListener interface The Nuptse compiler implements this Java interface to allow programmers to specify the mapping by annotating their C code The main benefit of this new approach is that it is way less intrusive First programmers can decide to organize their mapping information as they want either by annotating each C function or by gathering all these information in the header or even in another file But a greater benefit is encapsulation of legacy code Indeed it is very important when transforming a legacy code to encapsulate it into a component to modify the less pos sible the original code Why there a many reasons for that in is particularly important that subsequent evolutions of the original code can be applied to the transformed encap sulated code Typically if there a patch correcting a b
14. d gt bar lt barId gt where foold and barld are the identifiers of respectively the foo and bar sub components 3 3 Properties The Think ADL gives the possibility to attach properties to declarations of the different artifacts of the architecture model components client interfaces server interfaces attributes implementation and content files The syntax is lt propName gt lt propValue gt where propName and propValue are strings Properties give a way to pass infor mation to the different parts of the compiler For example the property binds foo i to bar i static true spec ifies that the binding between foo i and bar i will not change at runtime The builder of the client interfaces of foo that is responsible of the generation of code that makes the mapping between the identifier of a client interface and the identifier of the server interface it is bound to can take this property into account and generate direct calls for invocations of the methods of foo 1 attached to a component component lt propName gt lt propValue gt attached to a server interface requires lt propName gt lt propValue gt attached to a client interface provides lt propName gt lt propValue gt attached to an attribute attribute lt propName gt lt propValue gt attached to a binding 31 binds lt propName gt lt propValue gt
15. d to functional interfaces can be applied the same way to control interfaces Also it is possible to control the implementation of meta data corresponding to control interfaces as it is possible for functional interfaces As mentioned above NuptC provides privileges symbols for programming im plementation of control interfaces This keywords give a way to initialize implemen tation code with values concerning the architecture known at compile time and access and modify meta data at runtime All these keywords start with the META_ prefix 3 2 1 Client Interfaces Meta Data META_NB_CLT_ITFS Compile time value representing the number of client inter faces of the component 28 ETA_CLTITF_TABLE Variable name that declares a table containing the name and the id of each required interface This table must be declared as an array of any type which size must be at least the number of client interfaces The type if the table is transformed into a array of struct with two fields e itfName the name if the interface e itfId the id of the interface The table is initialized with values known at compile time For example if a component requires two interfaces foo and bar then the following declared variable any META_CLTITEF TABLE META_NB_CLTITES is transformed into the following code struct char itfName any itfld META CLTITF TABLE META NB_CLTITFS foo lt foold gt
16. e source code This is typically used when turning a C global variable into an attribute when encapsulating legacy code Note IgnoreDeclarations annotations may be implicitly deduced in the future from the Attributes or AttributePrefix annotations Examples In the following example the programmer specifies that the attribute att is represented by symbol aVar and that the declaration of the C global variable is to be ignored because the variable has be turned into the attribute att 25 Attribute att aVar 00 IgnoreDeclarations aVar Lese int aVar int bar int x aVar x 26 Chapter 3 Advanced Programming 3 1 Implementation Parts In the Fractalmodel a component may contain sub component or code that compose its the content and a primitive component is defined as follows A component that does not expose its content but has at least one control interface is called a primitive component To our understanding this definition does not prevent from having com ponents made of sub components and implementation code The approach taken in Think is to actually make no distinction between primitive and composite components since the property of being a primitive component is derived by other properties the fact that the component provides or not a ContentController interface A server interface can be either implemented by a sub component or directly by implementation code Another particu
17. efinition here is barl containing an abstract sub component c which definition is the abstract component definition here is fool and a concrete component definition here is barl that extends here is barl and overloading the abstract sub component c with a concrete sub component which definition is here is fool abstract component here is fool component here is foo2 extends here is fool 12 abstract component here is barl contains c here is foo component here is bar2 extends here is barl contains c here is foo2 2 3 2 7 singleton Usage Forces a component definition to be instanciated only once in a architecture singleton Description Forces a component definition to be instanciated only once in a archi tecture Two component instances of two different component definitions that contain a declaration of a sub component which definition is declared as singleton will share the same sub component instance at runtime Example The following code declares a singleton component definition here is foo a component definition here is bar1 that contains a sub component c1 of compo nent type here is foo and a component definition here is bar2 that contains a sub component c2 of component type here is foo and a sub component c3 of component type here is barl In a instance x of the component definition here is bar2 x c2 and x c3 c1 refer to the same shared component insta
18. enting function is the following C function declaration or definition Note that the methodName parameter refers to the IDL definition of the type of the interface whereas the serverInterfaceName refers to the name of the interface provided by the implemented component found in the corresponding ADL file Examples In the following example the programmer specifies that the C function myBar implements the method bar of the server interface foo ServerMethod foo bar myBar Ca int myBar int x It the second following example the programmer specifies that the C function bar following the annotation implements the server method ServerMethod foo bar int bar int x Predefined annotations For each method methodName of each interface it Name provided by the component Nuptse predefines the following annotation x ServerMethod lt itfName gt lt methodName gt SRV_ lt itfName gt __ lt methodName gt 2 4 2 2 DefaultServerMethods Usage Specifies that default symbol names will be used for representing server meth ods x DefaultServerMethods lt itfNamel gt lt itfName2 gt lt itfNameN gt QQ Description Specifies that the methods of server interfaces it fNamel it f NameN are implemented by C function having the same names than the methods of the inter face If no interface is given then this applies to all server
19. example illustrates the use of the annotation where the name of the function is omitted ClientMethod gnut gnat gnat eva PrivateMethod int prvMethod int x gnat x x ServerMethod foo bar int bar int x prvMethod x 2 24 Predefined annotation Functions that begin with PRV_ are considered as a private method That is for such a function named PRV_foo Nuptse predefines the following annotation 00 PrivateMethod PRV_foo 2 4 2 12 KeepName Usage Indicates to keep unchanged a C function 00 KeepName Description Specifies that the name of the following C function should not be changed by the Nuptse compiler This annotation can typically be used in case the function is to be called from assembly code that cannot be transformed by the compiler Examples In the following example the programmer specifies that the name of the C function bar representing the server method bar should not be changed by the compiler KeepName ServerMethod foo bar int bar int x 2 4 2 13 IgnoreDeclarations Usage Indicates to eliminate declaration of global variables from the C source code IgnoreDeclarations lt varNamel gt lt varNameN gt Description Specifies that the variables named varNamel varNameN should be eliminated by the compiler when transforming th
20. file Note that attributes can only be accessed from server or private methods Trying to access the attribute in a normal C function will raise an error Example In the following example the programmer specifies that the C variable symbol myVar represents the attribute att This attribute is accessed in function aMethod Attribute att aVar l int aMethod int x aVar aVar x return aVar 21 Predefined annotations For each attribute att Name Nuptse predefines the follow ing annotation 00 Attribute lt attName gt ATT_ lt attName gt 2 4 2 8 DefaultAttributes Usage Specifies that default symbol names will be used for representing attributes DefaultAttributes Description Specifies that the attributes of the components are represented by C vari able having the same names than the attributes This is a shortcut to writing the follow ing annotation for each attribute att ributeName Attribute lt attributeName gt lt attributeName gt Example In the following example the programmer specifies that attributes att 1 and att 2 are represented by C variable symbols with identical names These attributes are accessed in function aMet hod DefaultAttributes int aMethod int x attl attl x att2 x return attl att2 2 4 2 9 AttributesPrefix Usage Specifies the prefix of variables that repre
21. fy non functional properties of the component like the speed of a serial port on the size of a buffer The provided interfaces implemented by the content are called functional interfaces whereas the interfaces implemented by the membrane are called control interfaces The idea here is that the content implements functional as pects of the component whereas the membrane implements the non functional aspects and provides control over this non functional aspects One particular non functional aspect is the architectural one The Fractal model defines a set of interface types that may be implemented to control the architecture of a system at runtime namely e the Component interface that gives access to the interfaces provided by te com ponent e the BindingController interface that gives access to the interfaces re quired by the component and allows to change bindings e the ContentController that gives access to sub components if any and al lows to change the content of the component i e add remove sub components e the AttributeController that allows to get and set the value of an at tribute lOr both in the case of Think see section 3 1 for more details Remember that Fractal is a runtime component model This precision is impor tant since many other component models are design time models Fractal doesn t care about the design phase When taking about Fractal implementations like Julia or Think we are taking about framework
22. he following annotation x ClientMethod lt itfName gt lt methodName gt CLT_ lt itfName gt __ lt methodName gt x 19 2 4 2 5 DefaultClientMethods Usage Specifies that default symbol names will be used for representing client meth ods x DefaultClientMethods lt itfNamel gt lt itfName2 gt lt itfNameN gt Description Specifies that the methods of client interfaces it fNamel it fNameN are represented by C function having the same names than the methods of the interface If no interface is given then this applies to all client interfaces of the component Note that if two required interfaces have methods with the same name an error will be thrown if this annotation is used for both interfaces In that case the standard annota tion ClientMethod must be used for at least one of the conflicting interfaces This is a shortcut to writing the following annotation for each method methodName of each interface it fName required by the component x ClientMethod lt itfName gt lt methodName gt lt methodName gt Example In the following example the programmer specifies that methods bar and gnu of interface foo are represented by C function symbols with identical names These methods are called in function aMet hod DefaultClientMethods foo int aMethod int x foo x bar x 1 2 4 2 6 ClientInterfacePrefi
23. his interface type is defined methodDeclaration must be a valid C function prototype declaration and constantDeclaration must be a valid initialized C variable declaration The C types used in the declaration of methods and constants can be primitive C types ex int unsigned int short struct but also types defined in external files either a global file containing types which scope is the whole system which can be specified using the global typedefs file option passed to the compiler or using the typedefs keyword This keyword specifies that a file must be parsed before parsing the content of the interface definition and search for type definitions These types can then be used in method or constant declaration and also in code that implements server interface or that uses client interfaces of this interface type Note that if the prefix IDL typedefs compiler option is set to true uses of this types in the implementation code must be prefixed with the path of the interface type with dots replaced with underscores Example In the following example the interface type foo api Foo is defined as a method bar and a constant string CONST_STRING which value is hi Method bar takes a parameter a of type aType which is defined in file foo api aFile h package foo api typedefs aFile interface Foo char x CONST_STRING hi unsigned int bar aType a The content of file foo api aFile h is given bellow
24. ides a Component Programming Language CPL called NuptC to write the functional code implementing the provided interfaces of a component definition The CPL provides a way to the programmer to express the mapping between symbols defined in the ADL and IDL files corresponding to the component definition and the symbols in the C code that implements this component definition Contrary to previous CPLs of Think NuptC has been designed in order to e minimize the burden of the programers and clarify functional code by providing clear keywords representing the component concepts e allows optimizations by providing keywords that do not reflect particular imple mentation of the meta data Functional code is parsed by the compiler and is translated into an Abstract Se mantic Graph using the CodeGen librar Because NuptC does not extend the C grammar files can be parsed with the C parser provided by CodeGen and the compiler 3CodeGen is currently hosted by the Think project 15 implements a listener to handle the specific keywords This ASG is then analyzed and transformed by the build chain and the resulting C files are then produced before being compiled by a C compiler along with files containing the glue code Historically NuptC was extending the C language with architectural oriented re served identifiers having well defined naming conventions The grammar was the same but some identifiers were recognized as C mapping of architectur
25. larity of Think is that the implementation code of a component may be made of multiple implementation parts That is the set of services provided by a component may be split between multiple parts each responsible of a subset of the provided interfaces One important outcome of this choice is that different proper ties may be associated to different implementation parts For example it is possible to specify that the code implementing a control interface is shared between components while the code that implements a functional interface or another control interface is not or by specifying different builders for different implementation parts see section 3 7 When programming a component the basic way programmers do not have to care about implementation parts For this reason the Nuptse compilers defines a hidden implementation part named default with the following rules e any provided interface that is not bound to a sub component or is not imple mented by another implementation is implemented by the default implementa tion e any client interface can be called by the default implementation part e any content file which is not specified for a particular implementation part con tains code for the default implementation 27 The ADL provides the following keywords to specify required interfaces provided interfaces and content files for a particular implementation part Note that the current notation is subject to change in the fu
26. ly e the organization of descriptors using the embedded desc property see sec tion 3 3 1 Note that not using the this parameter in not shared implementations is distinguished to the not generation of the this parameter of single interfaces This is necessary be cause a client interface bound to a server interface which implementation is not shared may possibly be re bound to another server interface which implementation is not sin gle and that expects a valid this parameter to function properly Only if the server interface is single the this parameter need not to be passed because this means that there is and will be no other server that implements the same interface type and so client interfaces that are bound to it cannot be bound to another server interface pro vided type correctness of bound interfaces is satisfied 34 3 7 Meta Programming using builder specification The Think compiler provides a way to specify for each component which builders should be invoked This is done using the builder property TO BE COMPLETED 3 8 Entering component world 35
27. mponent only if it has client interfaces This is expressed using the hasC1tItf attribute as in the following example 33 component xx provides fractal api BindingController as binding controller in BindingController if hasCltItf 3 6 Compilation control and optimizations Programmers can control the generation of meta data using properties and use global extensions to apply the same properties to a set of components interfaces and separate this specification from the description of the architecture Using the default builders what can be currently controlled is e the placement of data using the attribute property see section 3 3 1 e the organization of descriptors using the embedded desc property see sec tion 3 3 1 Additionally the following optimizations are done e direct call are generated for static bindings and no meta data is generated for the client interface in the META_CLTITF_TABLE table e for code that is proper to a single component instance the addresses of meta data are known at compile time so the this parameter that may be generated for implementations of server methods is not used e for single implementation of server interfaces the this parameter is not gener ated for implementations of server methods and the this argument is not cal culated when calling such a method Combined with the previous optimization the this parameter disappear complete
28. nce component here is foo singleton component here is barl contains cl here is foo component here is bar2 contains c2 here is foo contains c3 here is barl 2 3 2 8 content Usage Specifies a file that contains implementation code 13 content lt fileName DotName gt raw Description Specifies that file which base name i e without extension is fileName with dot replaced with file separator contains implementation code The extension of the file name must be one of the following c s S If multiple files exist with the same base name the first file that fits the mentioned extensions will be used in the mentioned order Note multiple files may be specified for implementing the compo nent so that implementation code can be split across several files If raw is specified then the file contains code that does not directly implement server interfaces but usual C or assembly code instead and cannot make use of the model ar tifacts access attributes call client interfaces Files will be searched in the component repository path list specified in the command see Example In the following example if we suppose that rep1 and rep2 are in the repository path list in that order file rep1 a b f1 c contains code for the default implementation part files rep1 a b c f2 c and rep2 a b 3 c contain code for the implementation part imp1 file rep2 a b c
29. rfaces client interfaces and implementation This can typically be used to control the placement of glue de scriptors in memory sections rom ram flash embedded desc true false TO BE COMPLETED There are cases where such a directive cannot be satisfied For example if the component definition as constant attributes and there is multiple instances of such component definition with different values the if the attribute are implemented as constants then the code cannot be shared In this case shared false cannot be satisfied 32 3 4 Aspect Oriented Programming using Global Exten sions Mechanism The Architecture Description Language introduced in section 2 3 allows to define a component by extending another definition Starting from a initial definition it is pos sible to add new interfaces new attributes or new subcomponents It is also possible to specify new properties to existing interfaces attributes components In the follow ing the component definition stat icComp extends the definition comp by making static the declared interfaces component staticComp extends comp binds x i to y i static true binds x j to z j static true Nuptse introduces the notion of global extension as a way to extend multiple com ponent definitions in a AOP like manner using pattern matching An extension specifi cation is a standard ADL file but where names can have jokers that will be matched again
30. ry interfaces and will consequently fail 10 Example The following code declares in a component definition here is bar a required interface named foo of interface type here is Foo interface here is Foo void fool int a int b int foo2 char x component here is bar requires foo as here is Foo 2 3 2 4 attribute Usage Declares an attribute attribute lt attType Type gt lt attName Name gt lt value Expression gt const Description Declares an attribute named att Name of type att Type in a compo nent definition An initial value may be specified This will be the value of the attribute once the system initialized If const is specified the attribute will be constant that is will keep its initial value ant will not be modifiable at runtime Usage in the functional code may be replaced by the specified value so that trying to assign it in the functional code will possibly lead to a compile time error Example The following code declares three attributes in a component definition here is bar fool isan int and has no initial value 002 is of type short and will be instanciated with 3 as initial value oo3 is a constant char attribute which value is 10 and 004 is a constant string attribute which value is hello world component here is bar attribute int fool attribute short foo2 3 attribute char foo3 10 const attribute string foo4 hello world cons
31. s Functional code can be written in C extended with reserved names representing architectural artifacts This document is split into two chapters The first one details basic programming concepts and languages to design and implement basic components that is that should cover the requirements to design and implement say 90 of components The second chapter gives additional information on advanced concepts and languages to program control interfaces develop and specify non architectural aspect through properties and global extensions understand optimizations etc lFor historical reason this library is hosted by the Think project in the svn repository but may be extracted from it in a near future Chapter 2 Basic programming 2 1 Basic concepts A component in the Fractal sense is a runtime entity often called a component in stance A component has a type called a component type that defines the type of interactions the component can make An interface is an interaction point either an entry point called a server interface or a provided interface or an exit point called a client interface or a required interface In Fractal a component type is defined by the types of the interfaces that the component provides and requires A component has a content and a membrane the membrane having control over the content The content may consist of sub components or implementation codd A component may also have attributes that rei
32. s that are able to generate components that once loaded will be Fractal compliant components However frameworks like these do care about the design phase and provide languages to design components and program typically an Interface Description Language IDL and an Architecture Description Language ADL They also provide one or more compilers or tools to generate data that will help to create components 1 e component instances at runtime In this design phase we are out of the scope of the Fractal model though there are similarities One particular concept that does not exist at runtime is the concept of component definition A component definition is a component type it defines the set of client and server interfaces with additional information about how this component is imple mented In other component models this is often referred to as a component implemen tation of a component or component type In Think the concept of implementation rather refers to the code that implements server interfaces Think provides an IDL to express the types of interfaces and an ADL to express component definitions In the sense of programming languages what is defined in an IDL or an ADL file respectively interface types and component definitions is a type This is very similar to Java classes and interfaces that are defined in Java files they are types But beware a component definition which is a type in the ADL sense should not be confused with
33. sent the attributes of a component AttributesPrefix lt prefix gt Description Specifies that the attributes of the component are represented by C vari ables having the same name than the attributes prefixed with prefix This is a short cut to writing the following annotation for each attribute att ributeName of the component x Attribute lt attributeName gt lt prefix gt lt attributeName gt 22 Examples In the following example the programmer specifies that the attribute att 1 and att 2 are represented respectively by C variables att_att1 and att_att2 00 AttributesPrefix att_ int aMethod int x att_attl att_attl x att_att2 x return att_attl att_att2 2 4 2 10 PrivateData Usage Specifies a C global variable as a private data PrivateData lt variableName gt Description Specifies that the C variable var iableName will be a private variable Private variables are component variables that is each component instance of a com ponent definition will have its own instantiation of the declared private variables If parameter variableName is omitted then the annotation indicates that the variable declaration that follows is a private data Examples In the following example the programmer specifies that variable aVar is a private data which is accessed as a normal C variable in server method bar
34. st names found in an architecture description For example applying the following extension definition make all bindings static of any component definition component x binds x x to x x static true Th list of global extensions is specified with the ext files Users can also specify the option ext path to specify directories where to find extension files The com piler will first look in the ext path then in the src path when looking for global extensions Each global extension is matched against each component definition found in the architecture given as input to the build chain and it matches the original defini tion is extended accordingly Note that currently pattern expression is very limited only or exact names are supported at the moment More possibility based on Java pattern matching will be available in the future Also note that this not possible to specify a path to a component instance only names of component definition is supported at the moment This will be implemented in a near future These two limitations do not however invalidate the principles of the described approach 3 5 ADL predicates The ADL defines some predicates to condition some declarations This predicate are particularly useful in case of global extensions because they can be applied to different component definition having different structure For example it should be useful to add a BindingCont roller interface to a co
35. t 2 3 2 5 assigns Usage Assigns a value to an attribute of a sub component assigns lt subCompName Name gt lt attName Name gt lt value Expression gt 11 Description Assigns value value to attribure att Name of sub component subCompName subCompName must be the name of a sub component declared in the component def inition see 2 3 2 6 If the attribute was already declared with a value the latter is overwritten with the new value Example The following code declares a component definition here is foo that contains a sub component subComp of type here is bar and assigns a new value to its attribute att component here is bar attribute int att 1 component here is foo contains subComp here is bar assigns subComp att 2 2 3 2 6 contains Usage Declares a sub component in a component definition contains lt subCompName Name gt lt compDef DotName gt Description Declares a sub component subCompName of component type compDef in a component definition The notation declares an abstract sub component and must be used if and only if compDef is an abstract component definition In that case the enclosing component definition must also be declare as abstract Note how ever that an abstract component definition must not necessarily contains abstract sub components Example The following example declares an abstract component d
36. ture In the following example the programmer specifies that the provided interface foo is implemented by the implementation part anImplementationPart that is made of the content file aFile and may call the required interface bar here is Foo component here is bar Fee provides foo as here is Foo in anImplementationPart requires bar as here is Bar in anImplementationPart content aFile for anImplementation 3 2 Programming controllers Think provides a way to specify and implement control interfaces The approach taken in the Nuptse version is to make almost no distinction in the specification implemen tation and compilation of control and functional interfaces The only difference is that programmers of implementations of control interfaces can use privileged keyword to get access to meta data generated by the compiler This is very similar to the fact that in operating systems kernel code has accessed to privileged machine instruction that user code do not In addition the compiler distribution comes with a set of implemen tations of the standard Fractal interfaces This approach has the following benefits e it provides an uniform way to the programmers to specify and implement inter faces whatever they are control or functional interfaces e it makes possible to specify implement and use new control interfaces or pro gram new implementation of the Fractal interfaces e all optimizations that can be applie
37. ug it would be very interesting that the same patch can be applied to the encapsulated code NuptC annotations allow to specify the names of the C symbols that represent architectural concept Hence it is possible for example to specify that the original name of a C function is used to represent a server method so that there is no need to touch the original code to encap sulate it in a component definition The legacy example in the example directory of the compiler gives a simple example of a C code that has been encapsulated in components without touching a single line of the original code Note that the previous approach using naming conventions is still supported When programming components from scratch some developers prefer this old approach be cause it makes mapping symbol more explicit more visible To do this NuptC defines implicit annotations that make available these old style symbols These pre defined annotations are detailed in the following sections 2 4 2 NuptC annotations 2 4 2 1 ServerMethod Usage Declares a server method x ServerMethod lt serverInterfaceName gt lt methodName gt lt functionName gt x This behavior will be controllable in future releases through a compiler option 16 Description Specifies that the C function funct ionName implements the method methodName of the server interface serverInterfaceName If the parameter funct ionName is omitted then the repres
38. velopment by allowing intensive re use of pre defined software compo nent and rapid porting of infrastructure on new hardware targets The Think project http think objectweb org provides a compiler and several languages and mecha nisms to design and program components Since its first design Think has known several transformations through several versions The latest version Think v4 is known as Nuptse and focuses on simplcity and efficiency e it simplifies the burden of the developers of think based software by providing simplified languages especially for developers of functional code It enables enhancement and simplification e it makes possible the generation of very efficient software by providing the pos sibility to better master the flexibility power and implementation and so the associated cost of generated software The goal of this new version is to make Think useable to design and program com ponents for embedded applications and systems by taking into account the resource constraints specific to this application domain In particular we are targeting embed ded application like Wireless Network Sensors WSN This document focuses on the Nuptse version of Think A component library named Kortex is also hosted in the repository of the projec Kortex includes many components some of them being devoted to execution infras tructure and OS development memory manager interrupt handler semaphores run time scheduler
39. x Usage Specifies the prefix of functions that represents the methods of a client inter face x ClientInterfacePrefix lt clientInterfaceName gt lt prefix gt 00 Description Specifies that the methods of a required interface serverInterfaceNam are represented by C functions having the same name than the methods prefixed with prefix This is a shortcut to writing the following annotation for each method methodName of each interface it Name required by the component 20 x ClientMethod lt itfName gt lt methodName gt lt prefix gt lt methodName gt Examples In the following example the programmer specifies that the method bar and gnu of client interface foo are represented respectively by C functions ext __bar and ext_gnu ClientInterfacePrefix foo ext_ kas int aMethod int x ext_foo x ext_bar x 1 2 4 2 7 Attribute Usage Specifies the symbol representing an attribute Attribute lt attributeName gt lt varName gt Description Specifies that the C variable symbol varName represents the attribute attributeName Calls to the client method can then be made by a C call using this symbol Note that the methodName parameter refers to the IDL definition of the type of the interface whereas the serverInterfaceName refers to the name of the interface required by the implemented component found in the corresponding ADL
Download Pdf Manuals
Related Search
Related Contents
PROTEC`SOL - actalys.info Betriebs- und Instandhaltungsanleitung - STAHL クラウドロガー 取扱説明書 4 STiC2 User Guide PTC 213:2004 Requirements for Pay Telephones Betriebsanleitung für Talamex –Schlauchboote Class 210 Manuel d`installation 取扱説明書ダウンロード Copyright © All rights reserved.
Failed to retrieve file