]> git.lyx.org Git - lyx.git/blob - src/CmdDef.h
Avoid full metrics computation with Update:FitCursor
[lyx.git] / src / CmdDef.h
1 // -*- C++ -*-
2 /**
3  * \file CmdDef.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Bernhard Roider
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef CMDDEF_H
13 #define CMDDEF_H
14
15 #include "support/strfwd.h"
16
17 #include <map>
18 #include <set>
19
20 namespace lyx {
21
22 class FuncRequest;
23
24 /// Creates command definitions
25 class CmdDef {
26 private:
27         /// type for map between a macro name and its info
28         typedef std::map<std::string, FuncRequest> CmdDefMap;
29         /// type for a set containing all locked definitions
30         typedef std::set<std::string> LockSet;
31 public:
32
33         /// Parse a def file
34         bool read(std::string const & def_file);
35
36         /**
37          * Look up a definition, lock it and return the
38          * associated action if it is not locked.
39          * @param name the name of the command
40          * @param func contains the action on success
41          * @return true if lock was successful
42          */
43         bool lock(std::string const & name, FuncRequest & func);
44
45         /// release a locked definition
46         void release(std::string const & name);
47
48 private:
49
50         /// possible reasons for not allowed definitions
51         enum newCmdDefResult {
52                 CmdDefOk,
53                 CmdDefNameEmpty,
54                 CmdDefInvalid,
55                 CmdDefExists
56         };
57
58         /**
59          * Add a new command definition.
60          * @param name internal recursion level
61          */
62         newCmdDefResult newCmdDef(std::string const & name,
63                                       std::string const & def);
64
65         ///
66         CmdDefMap cmdDefMap;
67         ///
68         LockSet lockSet;
69 };
70
71 /// Implementation is in LyX.cpp
72 extern CmdDef & theTopLevelCmdDef();
73
74
75 } // namespace lyx
76
77 #endif // CMDDEF_H