Debian Codegraph @

plugins/aiksaurus/aiksaurusgtk3/AiksaurusGTK_histlist.cpp

raw
1 /*
2 * AiksaurusGTK - A GTK interface to the AikSaurus library
3 * Copyright (C) 2001 by Jared Davis
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
18 * 02111-1307, USA.
19 */
20
21 #include "AiksaurusGTK_histlist.h"
22 #include "AiksaurusGTK_strlist.h"
23
24 #ifndef NDEBUG
25 #include <iostream>
26 using namespace std;
27 #endif
28
29
30 AiksaurusGTK_histlist::AiksaurusGTK_histlist(unsigned int maxElements)
31 {
32 d_maxElements = maxElements;
33 d_list_ptr = new AiksaurusGTK_strlist;
34 }
35
36
37 AiksaurusGTK_histlist::~AiksaurusGTK_histlist()
38 {
39 delete d_list_ptr;
40 }
41
42
43 void AiksaurusGTK_histlist::addItem(const char* str)
44 {
45 d_list_ptr->remove_first(str);
46
47 d_list_ptr->push_front(str);
48
49 if (d_list_ptr->size() > d_maxElements)
50 {
51 d_list_ptr->pop_back();
52 }
53 }
54
55
56 const GList* AiksaurusGTK_histlist::list() const
57 {
58 return d_list_ptr->list();
59 }
60
61
62
63 #ifndef NDEBUG
64
65 void AiksaurusGTK_histlist::debug()
66 {
67 cout << "AiksaurusGTK_histlist::debug() {" << endl;
68 cout << " MaxElements is " << d_maxElements << endl;
69 cout << " List information follows: " << endl;
70 d_list_ptr->debug();
71 cout << "}" << endl;
72 }
73
74 #endif // NDEBUG
75