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