anuragraghavan / franca

Automatically exported from code.google.com/p/franca
0 stars 0 forks source link

Interface templates #112

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Java templates are a great help when designing generic interfaces with some 
variable types, which can be reused as kind of design patterns later.
This is very beneficial and largely used in Java for defining interfaces of 
Collections (lists, arrays, sets, maps) or any other generic interfaces which 
need to be adapted to application specific types.

Currently it is difficult to define similar semantics of lists together with a 
generic implementation in Franca and e.g. IPC CommonAPI, because due to the 
lacking possibility to use application specific data types, each application 
needs to define an individual set of list methods rather than being able to 
inherit a preexisting generic interface. It very hard to support code 
generation or framework utility classes supporting such generic functionality 
that way.

Proposed syntax for interface templates taken from Java:

// this is a generic interface which CAN NOT be used directly, but only by 
inheriting and filling in specific well defined data types. Implicitly this 
introduces another type of abstract interface.

interface Map<KEYTYPE, VALUETYPE> {
   method put {
      in {
         KEYTYPE key
         VALUETYPE value
      } out {
         VALUETYPE old
      }
   }
}

//------------ application specific part ----------
typedef struct mystruct {
   String name
   Int64 id
}

// this is the actual application interface which provides specific data types 
and makes the interface usable.
interface MyMapService extends Map<String,mystruct> {}

Original issue reported on code.google.com by manfred....@bmw.de on 13 Jun 2014 at 10:54

GoogleCodeExporter commented 9 years ago
This is an interesting idea, however, will be quite difficult to implement. We 
should detail the requirement a bit more, e.g., check which model elements 
should allow templating, if the model API should expose the template stuff to 
the downstream tools, if deployment is affected by this feature, ...

Original comment by klaus.birken@gmail.com on 8 Jul 2014 at 12:51

GoogleCodeExporter commented 9 years ago

Original comment by klaus.birken@gmail.com on 8 Jul 2014 at 1:19

GoogleCodeExporter commented 9 years ago
it would be sufficient to allow templates for interfaces.
If this template mechanism is envisioned like in Java, those templates should 
not be allowed to be implemented itself, but only as derived interfaces with 
all variable data types well defined. That way downstream code generators 
should not recognize any changes compared to Franca 0.9.0.
For transformations an additional API could provide visibility to template 
interfaces.

Original comment by manfred....@bmw.de on 23 Jul 2014 at 12:06

GoogleCodeExporter commented 9 years ago

Original comment by klaus.birken@gmail.com on 29 Jul 2014 at 9:45