tree.h

00001 // --*-c++-*-- 00002 /* 00003 $Id: tree_8h-source.html,v 1.1 2004/10/05 21:12:03 mentat Exp $ 00004 00005 GNU Messenger - The secure instant messenger 00006 Copyright (C) 2001-2003 Jesse Lovelace - jllovela@eos.ncsu.edu 00007 00008 This program is free software; you can redistribute it and/or modify 00009 it under the terms of the GNU General Public License as published by 00010 the Free Software Foundation; either version 2 of the License, or 00011 (at your option) any later version. 00012 00013 This program is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 GNU General Public License for more details. 00017 00018 You should have received a copy of the GNU General Public License 00019 along with this program; if not, write to the Free Software 00020 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00021 00022 */ 00023 00024 #ifndef GM_TREE_H 00025 #define GM_TREE_H 00026 00027 #include <string> 00028 #include "gm/xmlnode.h" 00029 00030 namespace GNUMessenger { 00031 00032 using namespace std; 00033 class Contact; 00034 00043 class Folder: public XMLNode 00044 { 00045 public: 00046 00047 Folder(); 00048 00049 Folder(const Folder& tree); 00050 Folder(const string& xml); 00051 00052 virtual ~Folder(); 00053 00054 virtual const string type() const { return "folder"; } 00055 00056 virtual const string& name() const { m_name = property("name"); return m_name; } 00057 virtual XMLNode& setName(const string& name) { setProperty("name", name); return *this; } 00058 00059 int countContacts() const { return numChildren("contact"); } 00060 int countFolders() const { return numChildren("folder"); } 00061 00062 Contact addContact(const string& name); 00063 Contact addContact(const Contact& contact); 00064 00065 Folder addFolder(const string& name); 00066 Folder addFolder(const Folder& Folder); 00067 00068 Contact getContact(const string& name) const; 00069 Folder getFolder(const string& name) const; 00070 00071 Contact contactAt(int index) const; 00072 Folder folderAt(int index) const; 00073 00076 Folder& operator=(const Folder &other); 00077 00078 00079 private: 00080 00081 // Since XMLNode::name() returns a reference, this extra 00082 // variable needs to be here to fake it. It must be 00083 // mutable to fake C++ bitwise const-ness 00084 mutable string m_name; 00085 00086 }; 00087 00088 } 00089 00090 #endif

Generated on Tue Oct 5 14:41:47 2004 for GNU Messenger by doxygen 1.3.8