/sqlite3cc

To get this branch, use:
bzr branch http://bzr.ed.am/sqlite3cc

« back to all changes in this revision

Viewing changes to include/sqlite3cc/connection.h

  • Committer: edam
  • Date: 2012-01-23 13:46:27 UTC
  • Revision ID: edam@waxworlds.org-20120123134627-i6hi9aftfvwgp8vw
updated autotols stuff

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * database.h
 
2
 * connection.h
3
3
 *
4
4
 * Copyright (C) 2009 Tim Marston <edam@waxworlds.org>
5
5
 *
20
20
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
21
 */
22
22
 
23
 
#ifndef SQLITE3CC_DATABASE_H_
24
 
#define SQLITE3CC_DATABASE_H_
 
23
#ifndef SQLITE3CC_CONNECTION_H_
 
24
#define SQLITE3CC_CONNECTION_H_
25
25
 
26
26
 
27
27
#include <sqlite3.h>
28
28
#include <boost/utility.hpp>
 
29
#include <string>
29
30
 
30
31
 
31
32
namespace sqlite
32
33
{
33
34
 
34
35
 
35
 
class basic_statement;
36
 
class transaction;
37
 
 
38
 
 
39
 
class database
 
36
namespace detail {
 
37
        class basic_statement;
 
38
        class basic_transaction;
 
39
}
 
40
 
 
41
 
 
42
class connection
40
43
        :
41
44
        private boost::noncopyable
42
45
{
43
46
//______________________________________________________________________________
 
47
//                                                                         types
 
48
public:
 
49
 
 
50
        /**
 
51
         * Class to provide a scope lock for the connection mutex
 
52
         */
 
53
        class mutex_guard
 
54
        {
 
55
        public:
 
56
 
 
57
                /**
 
58
                 * Constructor that provides a connection upon which to act
 
59
                 * @param connection reference to a connection
 
60
                 * @see sqlite3_db_mutex()
 
61
                 * @see sqlite3_mutex_enter()
 
62
                 */
 
63
                mutex_guard(
 
64
                        connection &connection );
 
65
 
 
66
                ~mutex_guard();
 
67
 
 
68
                /**
 
69
                 * Release the mutex early
 
70
                 * @see sqlite3_mutex_leave()
 
71
                 */
 
72
                void leave();
 
73
 
 
74
        private:
 
75
                sqlite3_mutex *_mutex;
 
76
        };
 
77
 
 
78
//______________________________________________________________________________
44
79
//                                                                 instantiation
45
80
public:
46
81
 
49
84
         * @param filename the filename of the database file to open
50
85
         * @throws database_error on error
51
86
         */
52
 
        explicit database(
 
87
        explicit connection(
53
88
                const std::string &filename );
54
89
 
55
 
        explicit database();
56
 
        virtual ~database();
 
90
        explicit connection();
 
91
        virtual ~connection();
57
92
 
58
93
//______________________________________________________________________________
59
94
//                                                              public interface
88
123
        /**
89
124
         * Sets a default busy handler which will
90
125
         * wait for the specified number of milliseconds.
91
 
         * @param milliseconds number of milliseconds to wait
 
126
         * @param duration number of milliseconds to wait
92
127
         * @returns an sqlite error code
93
128
         * @see sqlite3_busy_timeout()
94
129
         */
99
134
//                                                                implementation
100
135
private:
101
136
 
102
 
        friend class basic_statement;
 
137
        friend class detail::basic_statement;
 
138
        friend class detail::basic_transaction;
103
139
        friend class command;
 
140
        friend class sqlite_error;
104
141
 
105
 
        /** the database handle */
 
142
        /** the connection handle */
106
143
        sqlite3 *_handle;
107
144
 
108
145
};
111
148
} // namespace sqlite
112
149
 
113
150
 
114
 
#endif /* SQLITE3CC_DATABASE_H_ */
 
151
#endif /* SQLITE3CC_CONNECTION_H_ */