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.hh"
18
19#include <boost/shared_ptr.hpp>
20
21#include "database.hh"
22#include "key_store.hh"
23#include "lua_hooks.hh"
24#include "options.hh"
25#include "paths.hh"
26#include "project.hh"
27#include "vocab.hh"
28#include "work.hh"
29#include "ssh_agent.hh"
30
31namespace Botan
32{
33 class PK_Signer;
34 class RSA_PrivateKey;
35 class PK_Verifier;
36 class RSA_PublicKey;
37};
38
39// This class is supposed to hold all (or.. well, most) of the state
40// of the application, barring some unfortunate static objects like
41// the debugging / logging system and the command objects, for the
42// time being. The vague intent being to make life easier for anyone
43// who wants to embed this program as a library someday.
44
45class app_state
46{
47public:
48 database db;
49 lua_hooks lua;
50 key_store keys;
51 workspace work;
52 ssh_agent agent;
53
54 options opts;
55
56 bool found_workspace;
57 bool branch_is_sticky;
58 bool mtn_automate_allowed;
59
60 // These are used to cache signers/verifiers (if the hook allows).
61 // They can't be function-static variables in key.cc, since they
62 // must be destroyed before the Botan deinitialize() function is
63 // called.
64
65 std::map<rsa_keypair_id,
66 std::pair<boost::shared_ptr<Botan::PK_Signer>,
67 boost::shared_ptr<Botan::RSA_PrivateKey> > > signers;
68 std::map<rsa_keypair_id,
69 std::pair<boost::shared_ptr<Botan::PK_Verifier>,
70 boost::shared_ptr<Botan::RSA_PublicKey> > > verifiers;
71
72 void allow_workspace();
73 void process_options();
74 void require_workspace(std::string const & explanation = "");
75 void create_workspace(system_path const & dir);
76
77 // Set the branch name. If you only invoke set_branch, the branch
78 // name is not sticky (and won't be written to the workspace and
79 // reused by subsequent monotone invocations). Commands which
80 // switch the working to a different branch should invoke
81 // make_branch_sticky (before require_workspace because this
82 // function updates the workspace).
83
84 void make_branch_sticky();
85
86private:
87 project_t project;
88public:
89 //project_t & get_project(string const & name);
90 project_t & get_project(); // get_project(opts.project) or I()
91
92 void set_database(system_path const & filename);
93 void set_key_dir(system_path const & filename);
94 void set_diff_format(diff_type dtype);
95
96 explicit app_state();
97 ~app_state();
98
99private:
100 void load_rcfiles();
101 void write_options();
102};
103
104// Local Variables:
105// mode: C++
106// fill-column: 76
107// c-file-style: "gnu"
108// indent-tabs-mode: nil
109// End:
110// vim: et:sw=2:sts=2:ts=2:cino=>2s,{s,\:s,+s,t0,g0,^-2,e-2,n-2,p2s,(0,=s:
111
112#endif // __APP_STATE_HH__

Archive Download this file

Branches

Tags

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