Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!cs.utexas.edu!uunet!mcvax!kth!draken!tut!santra!hutcs.hut.fi!jaa From: jaa@hutcs.hut.fi (Jari Alasuvanto) Newsgroups: comp.lang.c++ Subject: Re: Objectifying incoming messages? Message-ID: <24013@santra.UUCP> Date: 28 Jul 89 06:33:16 GMT References: <444@cimshop.UUCP> <1273@cbnewsl.ATT.COM> Sender: news@santra.UUCP Reply-To: jaa@hutcs.hut.fi.UUCP (Jari Alasuvanto) Organization: Helsinki University of Technology, Finland Lines: 26 In article <1273@cbnewsl.ATT.COM> dog@cbnewsl.ATT.COM (edward.n.schiebel) writes: >The same problem arises reading objects from disk. Until you look at >the data, you don't know what class of object to instance so it >can read itself. It seems to me, this is one place you still >need a header/type field and a switch statement. > Or you can hide peeking at your data inside a library code as done in OOPS (NIH library). There you can read objects from disk and either give an expected class as an argument (the library code verifies it) or not give it. There are some problems in that, however: 1) Classes are not objects and there is no common base class in standard C++. A work-around is needed (as done in OOPS) 1) It may be hard to know later on what actually came - and you may have to do a case later on In our work we use the OOPS methods for writing the C++ objects into files to implement a simple persistent workspace as well as to exchange them via email - works fine. We need to tag the mail messages containing C++/NIH objects in order to be able to read also plain email. Jari Alasuvanto Lab. of Information Proc. Science, Helsinki Univ. of Techology, Finland Internet: jaa@hutcs.hut.fi Bitnet: jaa%finhutcs.bitnet tel: +358-0-451 3236 fax: +358-0-465 077