BTObject.hGo to the documentation of this file.00001 00006 /* 00007 Copyright (C) 2005 Anders Hedstrom 00008 00009 This program is free software; you can redistribute it and/or 00010 modify it under the terms of the GNU General Public License 00011 as published by the Free Software Foundation; either version 2 00012 of the License, or (at your option) any later version. 00013 00014 This program is distributed in the hope that it will be useful, 00015 but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 GNU General Public License for more details. 00018 00019 You should have received a copy of the GNU General Public License 00020 along with this program; if not, write to the Free Software 00021 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00022 */ 00023 #ifndef _BTOBJECT_H 00024 #define _BTOBJECT_H 00025 00026 #include <string> 00027 #include <vector> 00028 00029 00031 class BTObject 00032 { 00033 public: 00034 BTObject(size_t i) : m_parent(NULL),m_index(i),m_len(0) {} 00035 virtual ~BTObject() {} 00036 00037 virtual char Type() = 0; 00038 virtual void Show() { 00039 } 00040 00041 virtual void AddObject(BTObject *) {} 00042 virtual void AddObject(const std::string &,BTObject *) {} 00043 00044 BTObject *GetParent() { 00045 return m_parent; 00046 } 00047 void SetParent(BTObject *p) { 00048 m_parent = p; 00049 } 00050 std::string printable(const std::string& s) { 00051 std::string str; 00052 for (size_t i = 0; i < s.size(); i++) 00053 { 00054 if (isprint(s[i])) 00055 str += s[i]; 00056 else 00057 str += "."; 00058 } 00059 return str; 00060 } 00061 void Increase() { 00062 m_len++; 00063 if (m_parent) 00064 m_parent -> Increase(); 00065 } 00066 size_t GetLength() { return m_len; } 00067 size_t GetIndex() { return m_index; } 00068 00069 private: 00070 BTObject *m_parent; 00071 size_t m_index; 00072 size_t m_len; 00073 }; 00074 typedef std::vector<BTObject *> btobject_v; 00075 00076 00077 #endif // _BTOBJECT_H |