]> git.saurik.com Git - apple/xnu.git/blob - libkern/libkern/c++/OSBoolean.h
c228492b5f66e1710bdd3e99993a7b19cb9a06a8
[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 public:
43 static void initialize();
44
45 /*D
46 @function withBoolean
47 @abstract A static constructor function to create and initialize an instance of OSBoolean.
48 @param value A boolean value.
49 @result Returns and instance of OSBoolean, or 0 if an error occurred.
50 */
51 static OSBoolean *withBoolean(bool value);
52
53 /*D
54 @function free
55 @abstract A member function to release all resources used by the OSBoolean instance.
56 @discussion This function should not be called directly, use release() instead.
57 */
58 virtual void free();
59
60 /*!
61 @function isTrue
62 @abstract A member function to test if the boolean object is true.
63 @result Returns true if the OSBoolean object is true, false otherwise.
64 */
65 virtual bool isTrue() const;
66 /*!
67 @function isFalse
68 @abstract A member function to test if the boolean object is false.
69 @result Returns true if the OSBoolean object is false, false otherwise.
70 */
71 virtual bool isFalse() const;
72
73 /*!
74 @function getValue
75 @abstract Obtains the value of the OSBoolean object as the standard C++ type bool.
76 @result The value of the OSBoolean object.
77 */
78 virtual bool getValue() const;
79
80 /*!
81 @function isEqualTo
82 @abstract A member function to test the equality of two OSBoolean objects.
83 @param boolean An OSBoolean object to be compared against the receiver.
84 @result Returns true if the two objects are equivalent.
85 */
86 virtual bool isEqualTo(const OSBoolean *boolean) const;
87 /*!
88 @function isEqualTo
89 @abstract A member function to test the equality between an arbitrary OSObject derived object and an OSBoolean object.
90 @param obj An OSObject derived object to be compared against the receiver.
91 @result Returns true if the two objects are equivalent.
92 */
93 virtual bool isEqualTo(const OSMetaClassBase *obj) const;
94
95 /*!
96 @function serialize
97 @abstract A member function which archives the receiver.
98 @param s The OSSerialize object.
99 @result Returns true if serialization was successful, false if not.
100 */
101 virtual bool serialize(OSSerialize *s) const;
102
103 OSMetaClassDeclareReservedUnused(OSBoolean, 0);
104 OSMetaClassDeclareReservedUnused(OSBoolean, 1);
105 OSMetaClassDeclareReservedUnused(OSBoolean, 2);
106 OSMetaClassDeclareReservedUnused(OSBoolean, 3);
107 OSMetaClassDeclareReservedUnused(OSBoolean, 4);
108 OSMetaClassDeclareReservedUnused(OSBoolean, 5);
109 OSMetaClassDeclareReservedUnused(OSBoolean, 6);
110 OSMetaClassDeclareReservedUnused(OSBoolean, 7);
111 };
112
113 /*!
114 @defined kOSBooleanTrue
115 @abstract The OSBoolean constant for "true".
116 @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).
117 */
118 extern OSBoolean * const & kOSBooleanTrue;
119
120 /*!
121 @defined kOSBooleanFalse
122 @abstract The OSBoolean constant for "false".
123 @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).
124 */
125 extern OSBoolean * const & kOSBooleanFalse;
126
127 #endif /* !_OS_OSBOOLEAN_H */