custom_field.C

00001 /*
00002  * This file is part of the "Archon" framework.
00003  * (http://files3d.sourceforge.net)
00004  *
00005  * Copyright © 2002 by Kristian Spangsege and Brian Kristiansen.
00006  *
00007  * Permission to use, copy, modify, and distribute this software and
00008  * its documentation under the terms of the GNU General Public License is
00009  * hereby granted. No representations are made about the suitability of
00010  * this software for any purpose. It is provided "as is" without express
00011  * or implied warranty. See the GNU General Public License
00012  * (http://www.gnu.org/copyleft/gpl.html) for more details.
00013  *
00014  * The characters in this file are ISO8859-1 encoded.
00015  *
00016  * The documentation in this file is in "Doxygen" style
00017  * (http://www.doxygen.org).
00018  */
00019 
00020 /*
00021  * \file
00022  *
00023  *  Definition of custom fields as used in scripts.
00024  */
00025 
00026 #include <archon/x3d/server/custom_field.H>
00027 
00028 namespace Archon
00029 {
00030   namespace X3D
00031   {
00038     bool CustomFieldNode::addCustomField(Ref<CustomFieldBase> f)
00039       throw(RealizedException)
00040     {
00041       if(lookupField(f->getName())) return false;
00042       Mutex::Lock l(mutex);
00043       if(isRealizedNoLock()) ARCHON_THROW(RealizedException);
00044       customFields.push_back(f);
00045       return true;
00046     }
00047 
00048     const FieldBase *CustomFieldNode::lookupField(string name) const
00049     {
00050       {
00051         Mutex::Lock l(mutex);
00052         for(unsigned i=0; i<customFields.size(); ++i)
00053         {
00054           const FieldBase *f = customFields[i].get();
00055           if(f->getName() == name) return f;
00056         }
00057       }
00058       return getType()->lookupField(name);
00059     }
00060 
00061     /*
00062     string CustomFieldNode::dumpFields(int level) const
00063     {
00064       string s = getType()->dumpFields(this, level);
00065       for(unsigned i=0; i<customFields.size(); ++i)
00066         s += customFields[i]->dump(this, level);
00067       return s;
00068     }
00069     */
00070   }
00071 }

Generated on Sun Jul 30 22:55:49 2006 for Archon by  doxygen 1.4.4