summaryrefslogtreecommitdiff
path: root/lang/csharp/src/DatabaseStreamConfig.cs
blob: b42c9889c9a477316a657a8543e64de4f908d5a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*-
 * See the file LICENSE for redistribution information.
 *
 * Copyright (c) 2013, 2015 Oracle and/or its affiliates.  All rights reserved.
 *
 */
using System;
using System.Collections.Generic;
using System.Text;
using BerkeleyDB.Internal;

namespace BerkeleyDB {
    /// <summary>
    /// A class representing configuration parameters for
    /// <see cref="DatabaseStream"/>
    /// </summary>
    public class DatabaseStreamConfig {
        internal bool readOnlyIsSet;
        private bool readOnly;
        /// <summary>
        /// The database stream is read only.
        /// </summary>
        public bool ReadOnly {
            get {
                return readOnly;
            }
            set {
                readOnlyIsSet = true;
                readOnly = value;
            }
        }

        /// <summary>
        /// True if the database stream syncs the blob on each write.
        /// </summary>
        public bool SyncPerWrite;

        /// <summary>
        /// Instantiate a new DatabaseStreamConfig object.
        /// </summary>
        public DatabaseStreamConfig() {
            readOnly = false;
            SyncPerWrite = false;
        }

        internal uint flags {
            get {
                uint ret = 0;
                if (readOnlyIsSet)
                    ret |= readOnly ? DbConstants.DB_STREAM_READ :
                        DbConstants.DB_STREAM_WRITE;
                if (SyncPerWrite)
                    ret |= DbConstants.DB_STREAM_SYNC_WRITE;
                return ret;
            }
        }
    }
}