monotone

monotone Mtn Source Tree

Root/app_state.hh

1#ifndef __APP_STATE_HH__
2#define __APP_STATE_HH__
3
4// copyright (C) 2002, 2003 graydon hoare <graydon@pobox.com>
5// all rights reserved.
6// licensed to the public under the terms of the GNU GPL (>= 2)
7// see the file COPYING for details
8
9class app_state;
10class lua_hooks;
11
12#include <boost/shared_ptr.hpp>
13#include <botan/pubkey.h>
14#include <botan/rsa.h>
15
16#include <vector>
17
18#include "database.hh"
19#include "lua.hh"
20#include "work.hh"
21#include "vocab.hh"
22#include "paths.hh"
23#include "key_store.hh"
24
25// this class is supposed to hold all (or.. well, most) of the state of the
26// application, barring some unfortunate static objects like the debugging /
27// logging system and the command objects, for the time being. the vague intent
28// being to make life easier for anyone who wants to embed this program as a
29// library someday
30
31class app_state
32{
33public:
34 rsa_keypair_id signing_key;
35 utf8 branch_name;
36 database db;
37 lua_hooks lua;
38 key_store keys;
39 bool stdhooks;
40 bool rcfiles;
41 bool diffs;
42 bool no_merges;
43 bool set_default;
44 bool verbose;
45 options_map options;
46 utf8 message;
47 utf8 message_file;
48 utf8 date;
49 utf8 author;
50 system_path search_root;
51 utf8 sync_since;
52 bool cvspull_full;
53 std::vector<utf8> revision_selectors;
54 std::set<utf8> exclude_patterns;
55 std::vector<utf8> extra_rcfiles;
56 path_set restrictions;
57 path_set excludes;
58 bool found_working_copy;
59 long depth;
60 long last;
61 system_path pidfile;
62 diff_type diff_format;
63 bool diff_args_provided;
64 utf8 diff_args;
65 bool use_lca;
66 bool execute;
67 utf8 bind_address;
68 utf8 bind_port;
69 bool missing;
70 bool unknown;
71 std::vector<rsa_keypair_id> keys_to_push;
72 system_path confdir;
73 bool have_set_key_dir;
74
75 std::map<int, bool> explicit_option_map; // set if the value of the flag was explicitly given on the command line
76 void set_is_explicit_option (int option_id);
77 bool is_explicit_option(int option_id) const;
78
79 // These are used to cache signers/verifiers (if the hook allows).
80 // They can't be function-static variables in key.cc, since they must be
81 // destroyed before the Botan deinitialize() function is called. */
82 std::map<rsa_keypair_id,
83 std::pair<boost::shared_ptr<Botan::PK_Signer>,
84 boost::shared_ptr<Botan::RSA_PrivateKey> > > signers;
85 std::map<rsa_keypair_id,
86 std::pair<boost::shared_ptr<Botan::PK_Verifier>,
87 boost::shared_ptr<Botan::RSA_PublicKey> > > verifiers;
88
89 void allow_working_copy();
90 void require_working_copy(std::string const & explanation = "");
91 void create_working_copy(system_path const & dir);
92
93 void set_restriction(path_set const & valid_paths,
94 std::vector<utf8> const & paths,
95 bool respect_ignore = true);
96 bool restriction_includes(file_path const & path);
97
98 // Set the branch name. If you only invoke set_branch, the branch
99 // name is not sticky (and won't be written to the working copy and
100 // reused by subsequent monotone invocations). Commands which
101 // switch the working to a different branch should invoke
102 // make_branch_sticky (before require_working_copy because this
103 // function updates the working copy).
104 void set_branch(utf8 const & name);
105 void make_branch_sticky();
106
107 void set_database(system_path const & filename);
108 void set_key_dir(system_path const & filename);
109 void set_signing_key(utf8 const & key);
110 void set_root(system_path const & root);
111 void set_message(utf8 const & message);
112 void set_message_file(utf8 const & message_file);
113 void set_date(utf8 const & date);
114 void set_author(utf8 const & author);
115 void set_depth(long depth);
116 void set_since(utf8 const & since);
117 void set_last(long last);
118 void set_pidfile(system_path const & pidfile);
119 void add_revision(utf8 const & selector);
120 void add_exclude(utf8 const & exclude_pattern);
121 void set_diff_format(diff_type dtype);
122 void set_diff_args(utf8 const & args);
123 void add_key_to_push(utf8 const & key);
124
125 void set_stdhooks(bool b);
126 void set_rcfiles(bool b);
127 void set_verbose(bool b);
128 void add_rcfile(utf8 const & filename);
129
130 void set_confdir(system_path const & cd);
131 system_path get_confdir();
132
133 explicit app_state();
134 ~app_state();
135
136private:
137 void load_rcfiles();
138 void read_options();
139 void write_options();
140};
141
142#endif // __APP_STATE_HH__

Archive Download this file

Branches

Tags

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