00001 /* $Id: otdutil.hh,v 1.4 2003/07/22 05:09:53 tetron Exp $ 00002 00003 Copyright (C) 2002 Reed Hedges <reed@interreality.org> 00004 00005 This program is free software; you can redistribute it and/or modify 00006 it under the terms of the GNU General Public License as published by 00007 the Free Software Foundation; either version 2 of the License, or 00008 (at your option) any later version. 00009 00010 This program is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 GNU General Public License for more details. 00014 00015 You should have received a copy of the GNU General Public License 00016 along with this program; if not, write to the Free Software 00017 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00018 */ 00019 00020 00021 /* This code is partially based on the "outline.c" example distributed 00022 with expat. (debian: libexpat1-dev) 00023 00024 This code requires expat (debian: libexpat1, libexpat1-dev), and 00025 VOS core libs. 00026 */ 00027 00028 #ifndef _OTD_UTIL_HH_ 00029 #define _OTD_UTIL_HH_ 00030 00031 #include <deque> 00032 #include <vos/corelibs/vos/vos.hh> 00033 00034 00035 /** A small OTD utility library. Allows you to perform actions based on 00036 a local directory containing OTD files. Currently the only action 00037 available is the automatic creation of required subobjects. 00038 00039 @ingroup applibs 00040 @ingroup otdutil 00041 */ 00042 00043 namespace OTD { 00044 00045 /** Looks for OTDs in directories in the VOS_OTD_PATH environment 00046 variable, or in the default location if there is no such environment 00047 variable. 00048 If used, VOS_OTD_PATH should be a colon seperated list of directories. 00049 The default OTD directory is <INSTALL PREFIX>/share/vos/otd. 00050 */ 00051 void scan(); 00052 00053 /** Scan one directory 'dirname', recursing into subdirectories, 00054 parsing all OTDs until some basic info is gathered. 00055 Files are left open. 00056 */ 00057 void scanDir(string d); 00058 00059 /** Free heap memory and close all open files. */ 00060 void cleanup(); 00061 00062 /** Rescan the OTD directories for added/removed OTDs. 00063 @see scan() 00064 */ 00065 void rescan(); 00066 00067 /** Parse OTDs for each type string in 'types', and create required 00068 subobjects. If you have registered the Metaobjects extenders, then 00069 the created object of that type will contain that metaobject, otherwise, 00070 it will just have the typestring it its type list, but no metaobject 00071 instance attached. 00072 The new objects will be added as children with 00073 the correct names under 'vobj'. If site is 0, then the site for 00074 'vobj' is used to create the new objects. 00075 */ 00076 void initObject(deque<string>& types, Vobject* vobj, Site* site); 00077 00078 }; // ns OTD 00079 00080 00081 #endif // ifdef _OTD_UTIL_HH_