comp.lang.ada
 help / color / mirror / Atom feed
From: codeworker@free.fr (Cedric LEMAIRE)
Subject: Re: [ANN] an EBNF parser and coding pattern tool (LGPL)
Date: 15 Feb 2003 20:14:04 GMT
Date: 2003-02-15T20:14:04+00:00	[thread overview]
Message-ID: <clcm-20030215-0009@plethora.net> (raw)
In-Reply-To: clcm-20030211-0012@plethora.net

Stephen Leake <Stephen.A.Leake@nasa.gov> wrote in message news:<clcm-20030211-0012@plethora.net>...
> codeworker@free.fr (Cedric LEMAIRE) writes:
> 
> > How to write with C++ templates an "Object Unmarshaller", for
> > instance? I mean, something that reads the serialized content of an
> > object and that builds the corresponding object in memory. Be
> > careful! No intervention must be done on these objects in C++ to
> > facilitate their integration into the "unmarshaller".
> 
> C++ templates can't do this. Neither do Ada generics. But I could
> easily write a code generator to do this with ASIS.
> 
> Is there any language whose generics do this? 

Not a system programming language, but a scripting language: did you
try 'CodeWorker' at "http://codeworker.free.fr"? I implemented these
examples very easily in it.

> 
> > How to write an "Object Walker", something that enables to navigate
> > amongst the object attributes of the instances, for applying a task on
> > them (starting from a given object: to initialize all of them or to
> > serialize all of them or describing them in HTML to query the
> > application from a browser ...)?
> 
> You've lost me here.

I want to navigate amongst the object attributes of (an instance of) a
class, to apply a process on them.

  class A {
    ...
  public:
    virtual void accept(Visitor&);
  };

  class B {
    ...
    A* a;
  public:
    virtual void accept(Visitor&);
  };

  class C {
    ...
    A* a;
    std::vector<B*> list;
  public:
    virtual void accept(Visitor&);
  };

And now:
  void f(C& c) {
    HTMLVisitor processToApplyRecursivelyOnObjects;
    ObjectWalker walker(processToApplyRecursivelyOnObjects);
    walker.navigate(c);
  }

where the instance c and all its associations/aggregations (attributes
'a' and 'list') will be written in HTML, propagating the process on
object attributes (c.a and c.list[i] and c.list[i].a ...) recursively.

'HTMLVisitor' is a visitor that knows how to serialize in HTML all
instances of A, B and C. It cannot be written with C++ templates. By
hand? I'm used to work on Business applications of a few hundred
classes and a few thousand attributes (associations and other).

'ObjectWalker' cannot be written with C++ templates. It has to know
the composition of each class.

However, these classes can be written with 'CodeWorker' very easily.

> If I need to navigate a tree, I first have to
> build the tree, presumably using a tree class. Then the tree class
> must provide a "walker" (aka "iterator"). Where do "generics" or
> "templates" come into it?
> 
Your tree is an kind of 'abstract tree of object dependencies'. It is
an instance and its associations/aggregations. I don't want to build a
structure for it: it is already present as the representation of the
instance in memory.

Templates and generics aren't helpful here.

-- C�dric
-- 
comp.lang.c.moderated - moderation address: clcm@plethora.net



  parent reply	other threads:[~2003-02-15 20:14 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-01-24  3:36 [ANN] an EBNF parser and coding pattern tool (LGPL) Cedric LEMAIRE
2003-01-24 16:40 ` Victor Porton
2003-01-25  0:33   ` llewelly
2003-01-29  2:55   ` Cedric LEMAIRE
2003-01-24 16:40 ` apm
2003-01-29  2:56   ` Cedric LEMAIRE
2003-01-31  2:25     ` Cedric LEMAIRE
2003-01-31  2:25     ` Anthony Williams
2003-02-01  4:10       ` Cedric LEMAIRE
2003-02-04 16:53     ` apm
2003-02-06 20:35       ` Cedric LEMAIRE
2003-02-06 20:36       ` Cedric LEMAIRE
2003-02-01  4:09   ` White Wolf
2003-02-03  1:28     ` Martin Ambuhl
2003-02-03  1:28     ` Hillel Y. Sims
2003-02-03 16:31       ` Tars_Tarkas
2003-02-03  1:29     ` Mark McIntyre
2003-02-03 16:31       ` CBFalconer
2003-02-04 16:53         ` Georg Bauhaus
2003-02-06 20:36           ` Cedric LEMAIRE
2003-02-07 17:33             ` Hyman Rosen
2003-02-08 18:22               ` Thant Tessman
2003-02-07 17:33             ` Anthony Williams
2003-02-11  6:15               ` Cedric LEMAIRE
2003-02-12  1:30                 ` Hyman Rosen
2003-02-13 20:03                   ` Brian Inglis
2003-02-15 20:13                     ` Hyman Rosen
2003-02-15 20:14                   ` Cedric LEMAIRE
2003-02-12  1:30                 ` Julián Albo
2003-02-15 20:14                   ` Cedric LEMAIRE
2003-02-19  6:10                     ` Alan Balmer
2003-02-12  1:30                 ` Stephen Leake
2003-02-12 18:22                   ` Hyman Rosen
2003-02-12 19:39                     ` Stephen Leake
2003-02-12 21:16                       ` Hyman Rosen
2003-02-14 20:34                         ` Stephen Leake
2003-02-15 20:14                   ` Cedric LEMAIRE [this message]
2003-02-07 17:33             ` Hyman Rosen
2003-02-03 16:31       ` ozbear
2003-02-03 16:31     ` Cedric LEMAIRE
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox