home *** CD-ROM | disk | FTP | other *** search
/ Dream 52 / Amiga_Dream_52.iso / Linux / Divers / freedraft.tar.gz / freedraft.tar / FREEdraft-050298 / DRAWABLES / tabledrawables.cpp < prev    next >
C/C++ Source or Header  |  1998-04-19  |  2KB  |  55 lines

  1. // tabledrawables.h
  2.  
  3. // Copyright (C) 1998  Cliff Johnson                                       //
  4. //                                                                         //
  5. // This program is free software; you can redistribute it and/or           //
  6. // modify it under the terms of the GNU  General Public                    //
  7. // License as published by the Free Software Foundation; either            //
  8. // version 2 of the License, or (at your option) any later version.        //
  9. //                                                                         //
  10. // This software is distributed in the hope that it will be useful,        //
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of          //
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU       //
  13. // General Public License for more details.                                //
  14. //                                                                         //
  15. // You should have received a copy of the GNU General Public License       //
  16. // along with this software (see COPYING); if not, write to the        //
  17. // Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. //
  18. // 
  19.  
  20. #include <tabledrawables.h>
  21. #include <drawableexception.h>
  22. #include <drawablepoint.h>
  23. #include <drawableline.h>
  24. #include <drawablecircle.h>
  25. #include <drawablesegment.h>
  26. #include <drawablearc.h>
  27.  
  28. #include <drawable_enum.h>
  29.  
  30.  
  31. TableDrawables::TableDrawables()
  32. {
  33. // stick all the drawables into a map indexed by strings
  34. drawableMap.insert(pair<int,const DrawableGeom*>(FD_DRAWABLE_POINT,new DrawablePoint()));
  35. drawableMap.insert(pair<int,const DrawableGeom*>(FD_DRAWABLE_LINE,new DrawableLine()));
  36. drawableMap.insert(pair<int,const DrawableGeom*>(FD_DRAWABLE_CIRCLE,new DrawableCircle()));
  37. drawableMap.insert(pair<int,const DrawableGeom*>(FD_DRAWABLE_SEGMENT,new DrawableSegment()));
  38. drawableMap.insert(pair<int,const DrawableGeom*>(FD_DRAWABLE_ARC,new DrawableArc()));
  39. }
  40.  
  41. TableDrawables::~TableDrawables()
  42. {
  43.     for(map<int, const DrawableGeom*>::iterator ix =drawableMap.begin(); ix != drawableMap.end(); ix++)
  44.         delete (*ix).second;
  45.  
  46. }
  47.  
  48. const DrawableGeom* TableDrawables::Drawable(const int& i) const throw (DrawableException)
  49. {
  50.     map<int, const DrawableGeom*>::const_iterator ix = drawableMap.find(i);
  51.     if(ix == drawableMap.end())
  52.         throw DrawableException("TableDrawables::GetDrawable() : cannot find matching drawable");    
  53.     return (*ix).second;
  54. }
  55.