1/*-
2 * See the file LICENSE for redistribution information.
3 *
4 * Copyright (c) 2009 Oracle.  All rights reserved.
5 *
6 */
7using System;
8using System.Collections.Generic;
9using System.Text;
10using BerkeleyDB.Internal;
11
12namespace BerkeleyDB {
13    /// <summary>
14    /// A class to represent cache priority for database pages
15    /// </summary>
16    public class CachePriority {
17        private uint _priority;
18        internal uint priority {
19            get { return _priority; }
20            private set { _priority = value; }
21        }
22
23        private CachePriority(uint value) {
24            priority = value;
25        }
26
27        internal static CachePriority fromUInt(uint value) {
28            switch (value) {
29                case DbConstants.DB_PRIORITY_VERY_LOW:
30                    return VERY_LOW;
31                case DbConstants.DB_PRIORITY_LOW:
32                    return LOW;
33                case DbConstants.DB_PRIORITY_DEFAULT:
34                    return DEFAULT;
35                case DbConstants.DB_PRIORITY_HIGH:
36                    return HIGH;
37                case DbConstants.DB_PRIORITY_VERY_HIGH:
38                    return VERY_HIGH;
39                default:
40                    throw new ArgumentException("Invalid CachePriority value.");
41            }
42        }
43
44        /// <summary>
45        /// The lowest priority: pages are the most likely to be discarded.
46        /// </summary>
47        public static CachePriority VERY_LOW =
48            new CachePriority(DbConstants.DB_PRIORITY_VERY_LOW);
49        /// <summary>
50        /// The next lowest priority.
51        /// </summary>
52        public static CachePriority LOW =
53            new CachePriority(DbConstants.DB_PRIORITY_LOW);
54        /// <summary>
55        /// The default priority.
56        /// </summary>
57        public static CachePriority DEFAULT =
58                    new CachePriority(DbConstants.DB_PRIORITY_DEFAULT);
59        /// <summary>
60        /// The next highest priority.
61        /// </summary>
62        public static CachePriority HIGH =
63                    new CachePriority(DbConstants.DB_PRIORITY_HIGH);
64        /// <summary>
65        /// The highest priority: pages are the least likely to be discarded.
66        /// </summary>
67        public static CachePriority VERY_HIGH =
68                    new CachePriority(DbConstants.DB_PRIORITY_VERY_HIGH);
69    }
70}
71