00001 // -*- C++ -*- 00002 /***************************************************************************** 00003 * 00004 * |_|_|_ |_|_ |_ |_|_|_ |_ C O M M U N I C A T I O N 00005 * |_ |_ |_ |_ |_ |_ N E T W O R K S 00006 * |_ |_ |_ |_ |_ |_ C L A S S 00007 * |_|_|_ |_ |_|_ |_|_|_ |_|_|_|_ L I B R A R Y 00008 * 00009 * $Id: DirManager.h,v 1.4 2002/02/01 08:46:01 spee Exp $ 00010 * 00011 * CNClass: CNDirManager --- object management frontend 00012 * 00013 ***************************************************************************** 00014 * Copyright (C) 1992-2002 Communication Networks 00015 * Aachen University of Technology 00016 * D-52056 Aachen 00017 * Germany 00018 * Email: cncl-adm@comnets.rwth-aachen.de 00019 ***************************************************************************** 00020 * This file is part of the CN class library. All files marked with 00021 * this header are free software; you can redistribute it and/or modify 00022 * it under the terms of the GNU Library General Public License as 00023 * published by the Free Software Foundation; either version 2 of the 00024 * License, or (at your option) any later version. This library is 00025 * distributed in the hope that it will be useful, but WITHOUT ANY 00026 * WARRANTY; without even the implied warranty of MERCHANTABILITY or 00027 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00028 * License for more details. You should have received a copy of the GNU 00029 * Library General Public License along with this library; if not, write 00030 * to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, 00031 * USA. 00032 * 00033 * As an exception to this rule you may use this template to generate 00034 * your own classes. This does not cause these classes to be covered by 00035 * the GNU Library General Public License. This exception does not 00036 * however invalidate any other reasons why the resulting program must be 00037 * covered by the GNU Library General Public License. 00038 *****************************************************************************/ 00039 00040 #ifndef __DirManager_h 00041 #define __DirManager_h 00042 00043 00044 #include <CNCL/Class.h> 00045 #include <CNCL/Param.h> 00046 00047 #include <CNCL/Object.h> // Base class 00048 00049 extern CNClassDesc CN_DIRMANAGER; // CNClass CNDirManager description 00050 00051 #include <CNCL/HashDynamic.h> 00052 #include <CNCL/KeyString.h> 00053 #include <string.h> 00054 00056 const unsigned long DEFAULT_CAPACITY = 17; 00057 00061 class CNDirManager : public CNHashDynamic 00062 { 00063 00064 public: 00065 /****** Constructors ******************************************************/ 00067 CNDirManager(CNString directory_name = "root", char separator = '/'); 00070 CNDirManager(CNParam *); 00073 ~CNDirManager(); 00074 00075 /****** members ***********************************************************/ 00076 00078 CNDirManager *add_directory(CNString path); 00081 bool add_entry(CNString path, CNObject *object); 00082 // bool remove_directory(CNString& directory); 00085 bool delete_entry(CNString object, bool withObjects = FALSE); 00086 // CNObject *remove_entry(CNString object); 00089 CNObject *get_entry (CNString object) const; 00092 CNStringR get_name() const { return name; } 00093 // void clear(bool withObjects); 00094 00096 void prettyPrint(ostream &strm, CNString base = "", 00097 bool printDir = FALSE) const; 00098 00099 private: 00101 CNDirManager *find_directory(CNString path); 00102 00104 CNString name; 00106 char SEPARATOR; 00107 00108 /****** Member functions required by CNCL *********************************/ 00109 public: 00110 virtual CNClassDesc class_desc() const // CNClass description 00111 { 00112 return CN_DIRMANAGER; 00113 }; 00114 00116 virtual bool is_a(CNClassDesc desc) const // Type checking 00117 { 00118 return desc == CN_DIRMANAGER ? TRUE : CNObject::is_a(desc); 00119 }; 00120 00122 static CNDirManager *cast_from_object(CNObject *obj) 00123 { 00124 # ifdef NO_TYPE_CHECK 00125 return (CNDirManager *)obj; 00126 # else 00127 return (CNDirManager *)( !obj || obj->is_a(CN_DIRMANAGER) 00128 ? obj : fatal_type(obj->class_desc(), CN_DIRMANAGER) ); 00129 # endif 00130 } 00131 00132 // O/bject creation 00133 // static CNObject *new_object(CNParam *param = NIL) 00134 // { return param ? new CNDirManager(param) : new CNDirManager; } 00135 00136 00138 virtual void print(ostream &strm = cout) const; 00140 virtual void dump (ostream &strm = cout) const; 00141 }; 00142 00143 00144 #endif
1.2.13.1 written by Dimitri van Heesch,
© 1997-2001