1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 1995 Matthias Ettrich
7 * Copyright 1995-2000 The LyX Team.
10 * ====================================================== */
13 #pragma implementation
21 #ifdef SIGC_CXX_NAMESPACES
22 using SigC::Connection;
35 void Counter::set(int v)
41 void Counter::addto(int v)
47 int Counter::value() const
68 // We need this since we store the Counter's as pointers in
70 for (CounterList::iterator it = counterList.begin();
71 it != counterList.end();
77 void Counters::newCounter(string const & newc)
79 // First check if newc already exist
80 CounterList::iterator cit = counterList.find(newc);
81 // if alrady exist give warning and return
82 if (cit != counterList.end()) {
83 lyxerr << "The new counter already exist." << endl;
86 counterList[newc] = new Counter;
90 void Counters::newCounter(string const & newc, string const & oldc)
92 // First check if newc already exist
93 CounterList::iterator cit = counterList.find(newc);
94 // if already existant give warning and return
95 if (cit != counterList.end()) {
96 lyxerr << "The new counter already exist." << endl;
99 // then check if oldc exist
100 CounterList::iterator it = counterList.find(oldc);
101 // if not give warning and return
102 if (it == counterList.end()) {
103 lyxerr << "The old counter does not exist." << endl;
107 Counter * tmp = new Counter;
108 (*it).second->onstep.connect(slot(tmp,
110 counterList[newc] = tmp;
114 void Counters::set(string const & ctr, int val)
116 CounterList::iterator it = counterList.find(ctr);
117 if (it == counterList.end()) {
118 lyxerr << "Counter does not exist." << endl;
121 (*it).second->set(val);
125 void Counters::addto(string const & ctr, int val)
127 CounterList::iterator it = counterList.find(ctr);
128 if (it == counterList.end()) {
129 lyxerr << "Counter does not exist." << endl;
132 (*it).second->addto(val);
136 int Counters::value(string const & ctr) const
138 CounterList::const_iterator cit = counterList.find(ctr);
139 if (cit == counterList.end()) {
140 lyxerr << "Counter does not exist." << endl;
143 return (*cit).second->value();
147 void Counters::step(string const & ctr)
149 CounterList::iterator it = counterList.find(ctr);
150 if (it == counterList.end()) {
151 lyxerr << "Counter does not exist." << endl;
154 (*it).second->step();