POV-Ray : Newsgroups : povray.off-topic : Standard libraries : Re: Standard libraries Server Time
6 Sep 2024 11:15:32 EDT (-0400)
  Re: Standard libraries  
From: Darren New
Date: 8 Mar 2009 19:31:53
Message: <49b45569$1@news.povray.org>
Warp wrote:
> that objects could register themselves to some centralized, non-template
> factory, using their own typeid as key, so that the factory could create
> clones of those objects at runtime, based on those typeids.)


Actually, wouldn't this be clearer to do with virtual functions or pointers 
to functions anyway? Where does typeid make things better in that scenario? 
Isn't it just as easy to do something like

class Alpha : Beta {
    ....
    virtual const char * me() { return "Alpha:Beta"; }
    ....
}

and switch on that?  That even gives you a defined value, so you can (say) 
write it into a file and read it back on the next run to reload objects that 
serialized themselves or something. Plus, you avoid the overhead of putting 
RTTI type_info on *every* class, most of which probably won't be registered 
that way?

-- 
   Darren New, San Diego CA, USA (PST)
   My fortune cookie said, "You will soon be
   unable to read this, even at arm's length."


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.