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
24// this class is supposed to hold all (or.. well, most) of the state of the
25// application, barring some unfortunate static objects like the debugging /
26// logging system and the command objects, for the time being. the vague intent
27// being to make life easier for anyone who wants to embed this program as a
28// library someday
29
30class app_state
31{
32public:
33 rsa_keypair_id signing_key;
34 utf8 branch_name;
35 database db;
36 lua_hooks lua;
37 bool stdhooks;
38 bool rcfiles;
39 bool diffs;
40 bool no_merges;
41 bool set_default;
42 bool verbose;
43 options_map options;
44 utf8 message;
45 utf8 message_file;
46 utf8 date;
47 utf8 author;
48 system_path search_root;
49 std::vector<utf8> revision_selectors;
50 std::set<utf8> exclude_patterns;
51 std::vector<utf8> extra_rcfiles;
52 path_set restrictions;
53 path_set excludes;
54 bool found_working_copy;
55 long depth;
56 long last;
57 system_path pidfile;
58 diff_type diff_format;
59 bool diff_args_provided;
60 utf8 diff_args;
61 bool use_lca;
62 bool execute;
63
64
65
66 // These are used to cache signers/verifiers (if the hook allows).
67 // They can't be function-static variables in key.cc, since they must be
68 // destroyed before the Botan deinitialize() function is called. */
69 std::map<rsa_keypair_id,
70 std::pair<boost::shared_ptr<Botan::PK_Signer>,
71 boost::shared_ptr<Botan::RSA_PrivateKey> > > signers;
72 std::map<rsa_keypair_id,
73 std::pair<boost::shared_ptr<Botan::PK_Verifier>,
74 boost::shared_ptr<Botan::RSA_PublicKey> > > verifiers;
75
76 void allow_working_copy();
77 void require_working_copy(std::string const & explanation = "");
78 void create_working_copy(system_path const & dir);
79
80 void app_state::set_restriction(path_set const & valid_paths,
81 std::vector<utf8> const & paths,
82 bool respect_ignore = true);
83 bool restriction_includes(file_path const & path);
84
85 // Set the branch name. If you only invoke set_branch, the branch
86 // name is not sticky (and won't be written to the working copy and
87 // reused by subsequent monotone invocations). Commands which
88 // switch the working to a different branch should invoke
89 // make_branch_sticky (before require_working_copy because this
90 // function updates the working copy).
91 void set_branch(utf8 const & name);
92 void make_branch_sticky();
93
94 void set_database(system_path const & filename);
95 void set_signing_key(utf8 const & key);
96 void set_root(system_path const & root);
97 void set_message(utf8 const & message);
98 void set_message_file(utf8 const & message_file);
99 void set_date(utf8 const & date);
100 void set_author(utf8 const & author);
101 void set_depth(long depth);
102 void set_last(long last);
103 void set_pidfile(system_path const & pidfile);
104 void add_revision(utf8 const & selector);
105 void add_exclude(utf8 const & exclude_pattern);
106 void set_diff_format(diff_type dtype);
107 void set_diff_args(utf8 const & args);
108
109 void set_stdhooks(bool b);
110 void set_rcfiles(bool b);
111 void set_verbose(bool b);
112 void add_rcfile(utf8 const & filename);
113
114 explicit app_state();
115 ~app_state();
116
117private:
118 void load_rcfiles();
119 void read_options();
120 void write_options();
121};
122
123#endif // __APP_STATE_HH__

Archive Download this file

Branches

Tags

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