]> git.saurik.com Git - apple/xnu.git/blob - libkern/libkern/c++/OSBoolean.h
105a617cdb91f65758755b674ee211e1ddde7643
[apple/xnu.git] / libkern / libkern / c++ / OSBoolean.h
1 /*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
14 * agreement.
15 *
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
18 * file.
19 *
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
27 *
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
29 */
30 /* OSBoolean.cpp created by rsulack on Tue Oct 12 1999 */
31
32 #ifndef _OS_OSBOOLEAN_H
33 #define _OS_OSBOOLEAN_H
34
35 #include <libkern/c++/OSObject.h>
36
37 class OSString;
38
39 /*!
40 @class OSBoolean
41 @abstract Container class for boolean values.
42 */
43 class OSBoolean : public OSObject
44 {
45 OSDeclareDefaultStructors(OSBoolean)
46
47 protected:
48 bool value;
49
50 /*D @function taggedRelease
51 @abstract Overrides tagged release mechanism.
52 @param when Unused.
53 */
54 virtual void taggedRelease(const void *tag, const int when) const;
55
56 public:
57 static void initialize();
58
59 /*D
60 @function withBoolean
61 @abstract A static constructor function to create and initialize an instance of OSBoolean.
62 @param value A boolean value.
63 @result Returns and instance of OSBoolean, or 0 if an error occurred.
64 */
65 static OSBoolean *withBoolean(bool value);
66
67 /*D
68 @function free
69 @abstract A member function to release all resources used by the OSBoolean instance.
70 @discussion This function should not be called directly, use release() instead.
71 */
72 virtual void free();
73
74 /*D @function taggedRetain
75 @abstract Override tagged retain mechanism. */
76 virtual void taggedRetain(const void *tag) const;
77
78 /*!
79 @function isTrue
80 @abstract A member function to test if the boolean object is true.
81 @result Returns true if the OSBoolean object is true, false otherwise.
82 */
83 virtual bool isTrue() const;
84 /*!
85 @function isFalse
86 @abstract A member function to test if the boolean object is false.
87 @result Returns true if the OSBoolean object is false, false otherwise.
88 */
89 virtual bool isFalse() const;
90
91 /*!
92 @function getValue
93 @abstract Obtains the value of the OSBoolean object as the standard C++ type bool.
94 @result The value of the OSBoolean object.
95 */
96 virtual bool getValue() const;
97
98 /*!
99 @function isEqualTo
100 @abstract A member function to test the equality of two OSBoolean objects.
101 @param boolean An OSBoolean object to be compared against the receiver.
102 @result Returns true if the two objects are equivalent.
103 */
104 virtual bool isEqualTo(const OSBoolean *boolean) const;
105 /*!
106 @function isEqualTo
107 @abstract A member function to test the equality between an arbitrary OSObject derived object and an OSBoolean object.
108 @param obj An OSObject derived object to be compared against the receiver.
109 @result Returns true if the two objects are equivalent.
110 */
111 virtual bool isEqualTo(const OSMetaClassBase *obj) const;
112
113 /*!
114 @function serialize
115 @abstract A member function that archives the receiver.
116 @param s The OSSerialize object.
117 @result Returns true if serialization was successful, false if not.
118 */
119 virtual bool serialize(OSSerialize *s) const;
120
121 OSMetaClassDeclareReservedUnused(OSBoolean, 0);
122 OSMetaClassDeclareReservedUnused(OSBoolean, 1);
123 OSMetaClassDeclareReservedUnused(OSBoolean, 2);
124 OSMetaClassDeclareReservedUnused(OSBoolean, 3);
125 OSMetaClassDeclareReservedUnused(OSBoolean, 4);
126 OSMetaClassDeclareReservedUnused(OSBoolean, 5);
127 OSMetaClassDeclareReservedUnused(OSBoolean, 6);
128 OSMetaClassDeclareReservedUnused(OSBoolean, 7);
129 };
130
131 /*!
132 @const kOSBooleanTrue
133 @abstract The OSBoolean constant for "true".
134 @discussion The OSBoolean constant for "true". The object does not need to be retained or released. Comparisons of the form (booleanObject == kOSBooleanTrue) are acceptable and would be equivalent to (booleanObject->getValue() == true).
135 */
136 extern OSBoolean * const & kOSBooleanTrue;
137
138 /*!
139 @const kOSBooleanFalse
140 @abstract The OSBoolean constant for "false".
141 @discussion The OSBoolean constant for "false". The object does not need to be retained or released. Comparisons of the form (booleanObject == kOSBooleanFalse) are acceptable and would be equivalent to (booleanObject->getValue() == false).
142 */
143 extern OSBoolean * const & kOSBooleanFalse;
144
145 #endif /* !_OS_OSBOOLEAN_H */