From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: * X-Spam-Status: No, score=1.6 required=5.0 tests=BAYES_05,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,79354c36dcd6f9f6 X-Google-Attributes: gid103376,public From: paulg@loxinfo.co.th (Paul Sjoerdsma) Subject: Reading objects from a file Date: 1997/04/18 Message-ID: <335837a9.11747231@news.loxinfo.co.th>#1/1 X-Deja-AN: 235580064 Organization: Straight Line Solutions Reply-To: paulg@loxinfo.co.th Newsgroups: comp.lang.ada Date: 1997-04-18T00:00:00+00:00 List-Id: Hi, I'm just starting using Ada and I have a, hopefully simple, question. =46irst I'll explain what I am trying to do: I am rewriting a simple visualization program, which is used to output geological (actually micro-paleontological) data. The program needs to read frequence curves, process the data and output files. The data structures used (for the graphics part) will look something like: Graphic_Elem (base class) -- Line_Elem (child class) -- Polyline_Elem (child class) -- Solid_Elem (child class) etc The output would go tho=20 Graphic_Port (base class) Dxf_port (child class) Ascii_port (child class) There will also be a class Figure procedure Add(Figure, Graphic_Elem) procedure Draw(Figure, Graphic_Port) What I am looking for are methods for the Figure class procedure Read procedure Write in such a way that invoking Read(Figure) will build the appropriate structure. So when it encounters a saved Line_Elem in the file it will invoke the read procedure associated with the Line_Elem. I know that one way of doing it would be to write out a unique identifier as part of each Graphic_Elem and in Read(Figure) use a case statement. The problem is than that the knowledge about the different Graphic_Elem children is hardcoded in the Figure class. Can this be avoided? regards Paul