]> git.lyx.org Git - lyx.git/blob - src/counters.h
19014cc6fceb0b580eff76fe3fac767f9ee3b464
[lyx.git] / src / counters.h
1 // -*- C++ -*-
2
3 #ifndef COUNTERS_H
4 #define COUTNERS_H
5
6 #include <map>
7 #include <sigc++/signal_system.h>
8 #include "LString.h"
9
10 #ifdef SIGC_CXX_NAMESPACES
11 using SigC::Object;
12 using SigC::Signal0;
13 #endif
14
15
16 ///
17 class Counter : public Object {
18 public:
19         ///
20         Counter();
21         ///
22         void set(int v);
23         ///
24         void addto(int v);
25         ///
26         int value() const;
27         ///
28         void step();
29         ///
30         void reset();
31         ///
32         Signal0<void> onstep;
33 private:
34         ///
35         int value_;
36 };
37
38
39 /** This is a class of (La)TeX type counters. The counters is in a text
40     Style and can be reset by signals emitted from a single counter.
41 */
42 class Counters {
43 public:
44         ///
45         ~Counters();
46         ///
47         void newCounter(string const & newc);
48         ///
49         void newCounter(string const & newc, string const & oldc);
50         ///
51         void set(string const & ctr, int val);
52         ///
53         void addto(string const & ctr, int val);
54         ///
55         int value(string const & ctr) const;
56         ///
57         void step(string const & ctr);
58         // string refstep(string const & cou);
59 private:
60         ///
61         typedef std::map<string, Counter*> CounterList;
62         ///
63         CounterList counterList;
64 };
65
66 #endif