]> git.lyx.org Git - lyx.git/blob - src/counters.h
Create a grfx::Loader class and so move large chunks of code out of
[lyx.git] / src / counters.h
1 // -*- C++ -*-
2 /* This file is part of
3  * ======================================================
4  *
5  *           LyX, The Document Processor
6  *
7  *           Copyright 1995 Matthias Ettrich
8  *           Copyright 1995-2001 The LyX Team.
9  *
10  *
11  * ====================================================== */
12
13
14 #ifndef COUNTERS_H
15 #define COUNTERS_H
16
17 #ifdef __GNUG__
18 #pragma interface
19 #endif
20
21 #include "LString.h"
22
23 #include <boost/signals/signal0.hpp>
24 #include <boost/signals/trackable.hpp>
25
26 #include <map>
27
28 ///
29 class Counter : public boost::trackable {
30 public:
31         ///
32         Counter();
33         ///
34         void set(int v);
35         ///
36         void addto(int v);
37         ///
38         int value() const;
39         ///
40         void step();
41         ///
42         void reset();
43         ///
44         boost::signal0<void> onstep;
45 private:
46         ///
47         int value_;
48 };
49
50
51 /** This is a class of (La)TeX type counters. The counters is in a text
52     Style and can be reset by signals emitted from a single counter.
53 */
54 class Counters {
55 public:
56         ///
57         ~Counters();
58         ///
59         void newCounter(string const & newc);
60         ///
61         void newCounter(string const & newc, string const & oldc);
62         ///
63         void set(string const & ctr, int val);
64         ///
65         void addto(string const & ctr, int val);
66         ///
67         int value(string const & ctr) const;
68         ///
69         void step(string const & ctr);
70         // string refstep(string const & cou);
71 private:
72         ///
73         typedef std::map<string, Counter*> CounterList;
74         ///
75         CounterList counterList;
76 };
77
78 #endif