monotone

monotone Mtn Source Tree

Root/app_state.hh

1#ifndef __APP_STATE_HH__
2#define __APP_STATE_HH__
3
4// Copyright (C) 2002 Graydon Hoare <graydon@pobox.com>
5//
6// This program is made available under the GNU GPL version 2.0 or
7// greater. See the accompanying file COPYING for details.
8//
9// This program is distributed WITHOUT ANY WARRANTY; without even the
10// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11// PURPOSE.
12
13class app_state;
14class lua_hooks;
15
16#include <map>
17#include <vector>
18
19#include <boost/date_time/posix_time/posix_time.hpp>
20#include <boost/shared_ptr.hpp>
21
22#include "database.hh"
23#include "key_store.hh"
24#include "lua_hooks.hh"
25#include "paths.hh"
26#include "vocab.hh"
27#include "work.hh"
28
29namespace Botan
30{
31 class PK_Signer;
32 class RSA_PrivateKey;
33 class PK_Verifier;
34 class RSA_PublicKey;
35};
36
37// This class is supposed to hold all (or.. well, most) of the state
38// of the application, barring some unfortunate static objects like
39// the debugging / logging system and the command objects, for the
40// time being. The vague intent being to make life easier for anyone
41// who wants to embed this program as a library someday.
42
43class app_state
44{
45public:
46 rsa_keypair_id signing_key;
47 utf8 branch_name;
48 database db;
49 lua_hooks lua;
50 key_store keys;
51 bool recursive;
52 bool stdhooks;
53 bool rcfiles;
54 bool diffs;
55 bool no_merges;
56 bool set_default;
57 bool verbose;
58 options_map options;
59 utf8 message;
60 utf8 message_file;
61 bool date_set;
62 boost::posix_time::ptime date;
63 utf8 author;
64 system_path search_root;
65 std::vector<utf8> revision_selectors;
66 std::vector<utf8> exclude_patterns;
67 std::vector<utf8> extra_rcfiles;
68 bool found_workspace;
69 long depth;
70 long last;
71 long next;
72 system_path pidfile;
73 diff_type diff_format;
74 bool diff_args_provided;
75 bool diff_show_encloser;
76 utf8 diff_args;
77 bool execute;
78 utf8 bind_address;
79 utf8 bind_port;
80 bool bind_stdio;
81 bool use_transport_auth;
82 bool missing;
83 bool unknown;
84 std::vector<rsa_keypair_id> keys_to_push;
85 system_path confdir;
86 bool have_set_key_dir;
87 std::set<std::string> attrs_to_drop;
88 bool no_files;
89 bool requested_help;
90
91 // Set if the value of the flag was explicitly given on the command
92 // line.
93 std::map<int, bool> explicit_option_map;
94 void set_is_explicit_option (int option_id);
95 bool is_explicit_option(int option_id) const;
96
97 // These are used to cache signers/verifiers (if the hook allows).
98 // They can't be function-static variables in key.cc, since they
99 // must be destroyed before the Botan deinitialize() function is
100 // called.
101
102 std::map<rsa_keypair_id,
103 std::pair<boost::shared_ptr<Botan::PK_Signer>,
104 boost::shared_ptr<Botan::RSA_PrivateKey> > > signers;
105 std::map<rsa_keypair_id,
106 std::pair<boost::shared_ptr<Botan::PK_Verifier>,
107 boost::shared_ptr<Botan::RSA_PublicKey> > > verifiers;
108
109 void allow_workspace();
110 void process_options();
111 void require_workspace(std::string const & explanation = "");
112 void create_workspace(system_path const & dir);
113
114 // Set the branch name. If you only invoke set_branch, the branch
115 // name is not sticky (and won't be written to the workspace and
116 // reused by subsequent monotone invocations). Commands which
117 // switch the working to a different branch should invoke
118 // make_branch_sticky (before require_workspace because this
119 // function updates the workspace).
120
121 void set_branch(utf8 const & name);
122 void make_branch_sticky();
123
124 void set_database(system_path const & filename);
125 void set_key_dir(system_path const & filename);
126 void set_signing_key(utf8 const & key);
127 void set_root(system_path const & root);
128 void set_message(utf8 const & message);
129 void set_message_file(utf8 const & message_file);
130 void set_date(utf8 const & date);
131 void set_author(utf8 const & author);
132 void set_depth(long depth);
133 void set_last(long last);
134 void set_next(long next);
135 void set_pidfile(system_path const & pidfile);
136 void add_revision(utf8 const & selector);
137 void add_exclude(utf8 const & exclude_pattern);
138 void set_diff_format(diff_type dtype);
139 void set_diff_args(utf8 const & args);
140 void add_key_to_push(utf8 const & key);
141 void set_recursive(bool r = true);
142 void set_prog_name(utf8 const & prog_name);
143
144 void set_stdhooks(bool b);
145 void set_rcfiles(bool b);
146 void set_verbose(bool b);
147 void add_rcfile(utf8 const & filename);
148
149 void set_confdir(system_path const & cd);
150 system_path get_confdir();
151
152 explicit app_state();
153 ~app_state();
154
155 // Only use set_prog_name to set this; changes need to be propagated
156 // to the global ui object.
157 utf8 prog_name;
158
159private:
160 void load_rcfiles();
161 void read_options();
162 void write_options();
163};
164
165// Local Variables:
166// mode: C++
167// fill-column: 76
168// c-file-style: "gnu"
169// indent-tabs-mode: nil
170// End:
171// vim: et:sw=2:sts=2:ts=2:cino=>2s,{s,\:s,+s,t0,g0,^-2,e-2,n-2,p2s,(0,=s:
172
173#endif // __APP_STATE_HH__

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status