Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

SLLibrary.cc

Go to the documentation of this file.
00001 /*
00002     File:           SLLibrary.cc
00003 
00004     Function:       See header file
00005 
00006     Author(s):      Andrew Willmott
00007 
00008     Copyright:      (c) 1995-2000, Andrew Willmott
00009 */
00010 
00011 
00012 #include "gcl/SLLibrary.h"
00013 #include "gcl/PolyLib.h"
00014 #include "gcl/GCLConfig.h"
00015 #include "gcl/MRModel.h"
00016 #include <string.h>
00017 
00027 // --- SLLibrary methods ------------------------------------------------------
00028 
00029 
00030 SLLibrary::SLLibrary()
00031 {
00032 }
00033 
00034 Void SLLibrary::Create()
00035 {
00036     AddMember("group", new scGroup);
00037     AddMember("poly", new scPoly);
00038     AddMember("mr-model", new scMRModel);
00039 	::AddPolyObjects();
00040     
00041     name = "simple";
00042 }
00043 
00044 Void SLLibrary::FreeData(Void *obj)
00045 {
00046     scPrimitive *sp = (scPrimitive*) obj;
00047 
00048     delete sp;
00049 }
00050 
00051 Void SLLibrary::AddMember(scScenePtr objectPtr)
00052 {
00053     SetVoidItem(objectPtr->Label(), (scPrimitive*) objectPtr);
00054 }
00055 
00056 Void SLLibrary::AddMember(StrConst name, scPrimitive *objectPtr)
00057 {
00058     SetVoidItem(name, objectPtr);
00059 }
00060 
00061 scPrimitive *SLLibrary::Member(StrConst name)
00062 {
00063     scPrimitive *sp = (scPrimitive*) GetVoidItem(name);
00064 
00065     if (!sp)
00066     {
00067         cerr << "Object not in library: " << name << endl;
00068         return(0);
00069     }
00070     else
00071         return(sp);
00072 }
00073 
00074 Bool SLLibrary::MemberExists(StrConst name)
00075 {
00076     return(ItemExists(name));
00077 }
00078 
00079 Void SLLibrary::DeleteMember(StrConst name)
00080 {
00081     DeleteItem(name);
00082 }
00083 
00084 
00085 // --- Output operators -------------------------------------------------------
00086 
00087 
00088 class Printer : public HashIter
00089 {
00090 public: 
00091     Printer(ostream &s) : out(s) {};
00092     ostream &out;
00093     Void ProcessVoidItem(StrConst key, Void *data)
00094     { out << key << endl; }
00095 };
00096 
00097 ostream &operator << (ostream &s, SLLibrary &library)
00098 {
00099     Printer printer(s);
00100 
00101     library.Iterate(printer);
00102 
00103     return(s);
00104 }

Generated at Sat Aug 5 00:17:03 2000 for Graphics Class Library by doxygen 1.1.0 written by Dimitri van Heesch, © 1997-2000