#include <Rect.h>
Inheritance diagram for Rect:

Public Types | |
| typedef float | TupleItemType |
| typedef for our item type; used by the binary operators below | |
Public Member Functions | |
| Rect () | |
| Default Constructor. | |
| Rect (float l, float t, float r, float b) | |
| Constructor where you specify the left, top, right, and bottom coordinates. | |
| Rect (const Rect &rhs) | |
| Copy constructor. | |
| Rect (Point leftTop, Point rightBottom) | |
| Constructor where you specify the leftTop point and the rightBottom point. | |
| virtual | ~Rect () |
| Destructor. | |
| float | left () const |
| convenience method to get the left edge of this Rect | |
| float & | left () |
| convenience method to set the left edge of this Rect | |
| float | top () const |
| convenience method to get the top edge of this Rect | |
| float & | top () |
| convenience method to set the top edge of this Rect | |
| float | right () const |
| convenience method to get the right edge of this Rect | |
| float & | right () |
| convenience method to set the right edge of this Rect | |
| float | bottom () const |
| convenience method to get the bottom edge of this Rect | |
| float & | bottom () |
| convenience method to set the bottom edge of this Rect | |
| void | Set (float l, float t, float r, float b) |
| Set a new position for the rectangle. | |
| void | PrintToStream () const |
| Print the rectangle's current state to stdout. | |
| Point | LeftTop () const |
| Returns the left top corner of the rectangle. | |
| Point | RightBottom () const |
| Returns the right bottom corner of the rectangle. | |
| Point | LeftBottom () const |
| Returns the left bottom corner of the rectangle. | |
| Point | RightTop () const |
| Returns the right top corner of the rectangle. | |
| void | SetLeftTop (const Point p) |
| Set the left top corner of the rectangle. | |
| void | SetRightBottom (const Point p) |
| Set the right bottom corner of the rectangle. | |
| void | SetLeftBottom (const Point p) |
| Set the left bottom corner of the rectangle. | |
| void | SetRightTop (const Point p) |
| Set the right top corner of the rectangle. | |
| void | InsetBy (Point p) |
| Makes the rectangle smaller by the amount specified in both the x and y dimensions. | |
| void | InsetBy (float dx, float dy) |
| Makes the rectangle smaller by the amount specified in both the x and y dimensions. | |
| void | OffsetBy (Point p) |
| Translates the rectangle by the amount specified in both the x and y dimensions. | |
| void | OffsetBy (float dx, float dy) |
| Translates the rectangle by the amount specified in both the x and y dimensions. | |
| void | OffsetTo (Point p) |
| Translates the rectangle so that its top left corner is at the point specified. | |
| void | OffsetTo (float x, float y) |
| Translates the rectangle so that its top left corner is at the point specified. | |
| void | Rationalize () |
| If this Rect has negative width or height, modifies it to have positive width and height. | |
| Rect | operator & (Rect r) const |
| Returns a rectangle whose area is the intersecting subset of this rectangle's and (r)'s. | |
| Rect | operator| (Rect r) const |
| Returns a rectangle whose area is a superset of the union of this rectangle's and (r)'s. | |
| Rect & | operator|= (const Rect &rhs) |
| Causes this rectangle to be come the union of itself and (rhs). | |
| Rect & | operator &= (const Rect &rhs) |
| Causes this rectangle to be come the intersection of itself and (rhs). | |
| bool | Intersects (Rect r) const |
| Returns true iff this rectangle and (r) overlap in space. | |
| bool | IsValid () const |
| Returns true iff this rectangle's area is non imaginary (i.e. | |
| float | Width () const |
| Returns the width of this rectangle. | |
| int32 | IntegerWidth () const |
| Returns the width of this rectangle as an integer. | |
| float | Height () const |
| Returns the height of this rectangle. | |
| int32 | IntegerHeight () const |
| Returns the height of this rectangle as an integer. | |
| bool | Contains (Point p) const |
| Returns true iff this rectangle contains the specified point. | |
| bool | Contains (Rect p) const |
| Returns true iff this rectangle fully the specified rectangle. | |
| virtual bool | IsFixedSize () const |
| Part of the Flattenable API: Returns true. | |
| virtual uint32 | TypeCode () const |
| Part of the Flattenable API: Returns B_RECT_TYPE. | |
| virtual uint32 | FlattenedSize () const |
| Part of the Flattenable API: Returns 4*sizeof(float). | |
| uint32 | CalculateChecksum () const |
| Returns a 32-bit checksum for this object. | |
| virtual void | Flatten (uint8 *buffer) const |
| Flattens this rectangle into an endian-neutral byte buffer. | |
| virtual status_t | Unflatten (const uint8 *buffer, uint32 size) |
| Unflattens this rectangle from an endian-neutral byte buffer. | |
| virtual bool | AllowsTypeCode (uint32 code) const |
| Should return true iff a buffer with uint32 (code) can be used to reconstruct this object's state. | |
| status_t | CopyTo (Flattenable ©To) const |
| Causes (copyTo)'s state to set from this Flattenable, if possible. | |
| status_t | CopyFrom (const Flattenable ©From) |
| Causes our state to be set from (copyFrom)'s state, if possible. | |
| status_t | FlattenToByteBuffer (ByteBuffer &outBuf) const |
| Convenience method. | |
| Ref< ByteBuffer > | FlattenToByteBuffer () const |
| Convenience method. | |
| status_t | UnflattenFromByteBuffer (const ByteBuffer &buf) |
| Convenience method. | |
| status_t | FlattenToDataIO (DataIO &outputStream, bool addSizeHeader) const |
| Convenience method. | |
| status_t | UnflattenFromDataIO (DataIO &inputStream, int32 optReadSize, uint32 optMaxReadSize=MUSCLE_NO_LIMIT) |
| Convenience method. | |
| Tuple & | operator+= (const Tuple &rhs) |
| Adds all indices in (rhs) to their counterparts in this object. | |
| Tuple & | operator+= (const float &value) |
| Adds (value) to all indices in this object. | |
| Tuple & | operator-= (const Tuple &rhs) |
| Subtracts all indices in (rhs) from their counterparts in this object. | |
| Tuple & | operator-= (const float &value) |
| Subtracts (value) from all indices in this object. | |
| Tuple & | operator *= (const Tuple &rhs) |
| Multiplies all indices in this object by their counterparts in this (rhs). | |
| Tuple & | operator *= (const float &value) |
| Multiplies all indices in this object by (value). | |
| Tuple & | operator/= (const Tuple &rhs) |
| Divides all indices in this object by their counterparts in this object (rhs). | |
| Tuple & | operator/= (const float &value) |
| Divides all indices in this object by (value). | |
| Tuple & | operator<<= (int numPlaces) |
| Shifts the values of the indices left (numPlaces) spaces. | |
| Tuple & | operator>>= (int numPlaces) |
| Shifts the values of the indices right (numPlaces) spaces. | |
| bool | operator== (const Tuple &rhs) const |
| Returns true iff all indices in this object are equal to their counterparts in (rhs). | |
| bool | operator!= (const Tuple &rhs) const |
| Returns true iff any indices in this object are not equal to their counterparts in (rhs). | |
| bool | operator< (const Tuple &rhs) const |
| Comparison Operator. | |
| bool | operator> (const Tuple &rhs) const |
| Comparison Operator. | |
| bool | operator<= (const Tuple &rhs) const |
| Comparison Operator. | |
| bool | operator>= (const Tuple &rhs) const |
| Comparison Operator. | |
| float & | operator[] (uint32 i) |
| Read-write array operator (not bounds-checked). | |
| const float & | operator[] (uint32 i) const |
| Read-only array operator (not bounds-checked). | |
| float | DotProduct (const Tuple &rhs) const |
| Returns the dot-product of (this) and (rhs). | |
| int | IndexOf (const float &value) const |
| Returns the index of the first value equal to (value), or -1 if not found. | |
| int | LastIndexOf (const float &value) const |
| Returns the index of the last value equal to (value), or -1 if not found. | |
| int | Compare (const Tuple &rhs) const |
| Works like strcmp(), only for a tuple. | |
| float | GetMaximumValue () const |
| Returns the minimum value from amongst all the items in the tuple. | |
| float | GetMinimumValue () const |
| Returns the maximum value from amongst all the items in the tuple. | |
| float | GetLengthSquared () const |
| Multiplies each value by itself, and returns the sum. | |
| uint32 | GetNumInstancesOf (const float &value) const |
| Returns the number of times (value) appears in this tuple. | |
| bool | MatchSubrange (const Tuple &matchAgainst, uint32 startIndex=0, uint32 endIndex=MUSCLE_NO_LIMIT) const |
| Returns true iff the all index values in the given range match those of the given Tuple. | |
| void | FillSubrange (floatvalue, uint32 startIndex=0, uint32 endIndex=MUSCLE_NO_LIMIT) |
| Sets all items in the range [startIndex, endIndex] (inclusive) to (value). | |
| uint32 | Replace (const float &replaceMe, const float &withMe, uint32 startIndex=0, uint32 endIndex=MUSCLE_NO_LIMIT) |
| Replaces all instances of (replaceMe) with (withMe). | |
| void | CopySubrange (const Tuple &rhs, uint32 startIndex=0, uint32 endIndex=MUSCLE_NO_LIMIT) |
| Sets all items in the range [startIndex, endIndex] (inclusive) to be equal to their counterparts in (rhs). | |
| void | Reset () |
| Sets all our items to their zero/default values. | |
| const uint32 | GetNumItemsInTuple () const |
| How many items in this tuple. | |
| float * | GetItemPointer (uint32 which) |
| Convenience method -- returns a pointer to the nth item in our tuple. | |
| const float * | GetItemPointer (uint32 which) const |
| Convenience method -- returns a read-only pointer to the nth item in our tuple. | |
Static Public Member Functions | |
| static void | WriteData (uint8 *outBuf, uint32 *writeOffset, const void *copyFrom, uint32 blockSize) |
| Convenience method for writing data into a byte buffer. | |
| static status_t | ReadData (const uint8 *inBuf, uint32 inputBufferBytes, uint32 *readOffset, void *copyTo, uint32 blockSize) |
| Convenience method for safely reading bytes from a byte buffer. | |
Protected Member Functions | |
| virtual status_t | CopyFromImplementation (const Flattenable ©From) |
| Called by CopyFrom() and CopyTo(). | |
Definition at line 22 of file Rect.h.
| Rect::Rect | ( | ) | [inline] |
| bool Rect::IsValid | ( | ) | const [inline] |
| virtual void Rect::Flatten | ( | uint8 * | buffer | ) | const [inline, virtual] |
Flattens this rectangle into an endian-neutral byte buffer.
| buffer | Points to the byte buffer to write into. There must be at least FlattenedSize() bytes there. |
Implements Flattenable.
| virtual status_t Rect::Unflatten | ( | const uint8 * | buffer, | |
| uint32 | size | |||
| ) | [inline, virtual] |
Unflattens this rectangle from an endian-neutral byte buffer.
| buffer | Points to the byte buffer to read data from. | |
| size | The number of bytes available in (buffer). There should be at least FlattenedSize() bytes there. |
Implements Flattenable.
Definition at line 215 of file Rect.h.
References bottom(), FlattenedSize(), left(), right(), and top().
| virtual bool Flattenable::AllowsTypeCode | ( | uint32 | code | ) | const [inline, virtual, inherited] |
Should return true iff a buffer with uint32 (code) can be used to reconstruct this object's state.
Defaults implementation returns true iff (code) equals TypeCode() or B_RAW_DATA.
| code | A type code constant, e.g. B_RAW_TYPE or B_STRING_TYPE, or something custom. |
Reimplemented in ByteBuffer.
Definition at line 56 of file Flattenable.h.
References Flattenable::TypeCode().
Referenced by Flattenable::CopyFrom(), and Flattenable::CopyTo().
| status_t Flattenable::CopyTo | ( | Flattenable & | copyTo | ) | const [inline, inherited] |
Causes (copyTo)'s state to set from this Flattenable, if possible.
Default implementation is not very efficient, since it has to flatten this object into a byte buffer, and then unflatten the bytes back into (copyTo). However, you can override CopyFromImplementation() to provide a more efficient implementation when possible.
| copyTo | Object to make into the equivalent of this object. (copyTo) May be any subclass of Flattenable. |
Definition at line 76 of file Flattenable.h.
References Flattenable::AllowsTypeCode(), Flattenable::CopyFromImplementation(), and Flattenable::TypeCode().
| status_t Flattenable::CopyFrom | ( | const Flattenable & | copyFrom | ) | [inline, inherited] |
Causes our state to be set from (copyFrom)'s state, if possible.
Default implementation is not very efficient, since it has to flatten (copyFrom) into a byte buffer, and then unflatten the bytes back into (this). However, you can override CopyFromImplementation() to provide a more efficient implementation when possible.
| copyFrom | Object to read from to set the state of this object. (copyFrom) may be any subclass of Flattenable. |
Definition at line 91 of file Flattenable.h.
References Flattenable::AllowsTypeCode(), Flattenable::CopyFromImplementation(), and Flattenable::TypeCode().
| static void Flattenable::WriteData | ( | uint8 * | outBuf, | |
| uint32 * | writeOffset, | |||
| const void * | copyFrom, | |||
| uint32 | blockSize | |||
| ) | [inline, static, inherited] |
Convenience method for writing data into a byte buffer.
Writes data consecutively into a byte buffer. The output buffer is assumed to be large enough to hold the data.
| outBuf | Flat buffer to write to | |
| writeOffset | Offset into buffer to write to. Incremented by (blockSize) on success. | |
| copyFrom | memory location to copy bytes from | |
| blockSize | number of bytes to copy |
Definition at line 105 of file Flattenable.h.
| static status_t Flattenable::ReadData | ( | const uint8 * | inBuf, | |
| uint32 | inputBufferBytes, | |||
| uint32 * | readOffset, | |||
| void * | copyTo, | |||
| uint32 | blockSize | |||
| ) | [inline, static, inherited] |
Convenience method for safely reading bytes from a byte buffer.
(Checks to avoid buffer overrun problems)
| inBuf | Flat buffer to read bytes from | |
| inputBufferBytes | total size of the input buffer | |
| readOffset | Offset into buffer to read from. Incremented by (blockSize) on success. | |
| copyTo | memory location to copy bytes to | |
| blockSize | number of bytes to copy |
Definition at line 120 of file Flattenable.h.
| status_t Flattenable::FlattenToByteBuffer | ( | ByteBuffer & | outBuf | ) | const [inherited] |
Convenience method.
Flattens this object into the supplied ByteBuffer object.
| outBuf | the ByteBuffer to dump our flattened bytes into. |
| Ref<ByteBuffer> Flattenable::FlattenToByteBuffer | ( | ) | const [inherited] |
Convenience method.
Allocated an appropriately sized ByteBuffer object via GetByteBufferFromPool(), Flatten()s this object into the byte buffer, and returns the resulting ByteBufferRef. Returns a NULL reference on failure (out of memory?)
| status_t Flattenable::UnflattenFromByteBuffer | ( | const ByteBuffer & | buf | ) | [inherited] |
Convenience method.
Unflattens this object from the supplied ByteBuffer object.
| buf | The ByteBuffer to unflatten from. |
| status_t Flattenable::FlattenToDataIO | ( | DataIO & | outputStream, | |
| bool | addSizeHeader | |||
| ) | const [inherited] |
Convenience method.
Flattens this object to the given DataIO object.
| outputStream | The DataIO object to send our flattened data to. This DataIO should be in blocking I/O mode; this method won't work reliably if used with non-blocking I/O. | |
| addSizeHeader | If true, we will prefix our flattened data with a four-byte little-endian uint32 indicating the number of bytes of flattened data that we are going to write. If false, then the buffer size will need to be determined by the reading code by some other means. |
| status_t Flattenable::UnflattenFromDataIO | ( | DataIO & | inputStream, | |
| int32 | optReadSize, | |||
| uint32 | optMaxReadSize = MUSCLE_NO_LIMIT | |||
| ) | [inherited] |
Convenience method.
Flattens this object from the given DataIO object.
| inputStream | the DataIO object to read data from. This DataIO should be in blocking I/O mode; this method won't work reliably if used with non-blocking I/O. | |
| optReadSize | If non-negative, this many bytes will be read from (inputStream). If set to -1, then the first four bytes read from the stream will be used to determine how many more bytes should be read from the stream. If the data was created with Flatten(io, true), then set this parameter to -1. | |
| optMaxReadSize | An optional value indicating the largest number of bytes that should be read by this call. This value is only used if (optReadSize) is negative. If (optReadSize) is negative and the first four bytes read from (inputStream) are greater than this value, then this method will return B_ERROR instead of trying to read that many bytes. This can be useful if you want to prevent the possibility of huge buffers being allocated due to malicious or corrupted size headers. Defaults to MUSCLE_NO_LIMIT, meaning that no size limit is enforced. |
| virtual status_t Flattenable::CopyFromImplementation | ( | const Flattenable & | copyFrom | ) | [protected, virtual, inherited] |
Called by CopyFrom() and CopyTo().
Sets our state from (copyFrom) if possible. Default implementation is not very efficient, since it has to flatten (copyFrom) into a byte buffer, and then unflatten the bytes back into (this). However, you can override CopyFromImplementation() to provide a more efficient implementation when possible.
| copyFrom | Object to set this object's state from. May be any subclass of Flattenable, but it has been pre-screened by CopyFrom() (or CopyTo()) to make sure it's not (*this), and that we allow its type code. |
Reimplemented in Message, and ByteBuffer.
Referenced by Flattenable::CopyFrom(), and Flattenable::CopyTo().
| bool Tuple< NumItems, float >::MatchSubrange | ( | const Tuple< 4, float > & | matchAgainst, | |
| uint32 | startIndex = 0, |
|||
| uint32 | endIndex = MUSCLE_NO_LIMIT | |||
| ) | const [inline, inherited] |
Returns true iff the all index values in the given range match those of the given Tuple.
| matchAgainst | The Tuple to do a partial index value match against | |
| startIndex | The first index to match on. Defaults to zero. | |
| endIndex | The last index to match on, plus one. Values that are greater than the number of items in the tuple will be capped to (the number of items in the tuple). Defaults to MUSCLE_NO_LIMIT. |
| void Tuple< NumItems, float >::FillSubrange | ( | float | value, | |
| uint32 | startIndex = 0, |
|||
| uint32 | endIndex = MUSCLE_NO_LIMIT | |||
| ) | [inline, inherited] |
Sets all items in the range [startIndex, endIndex] (inclusive) to (value).
| value | The value to set items to. | |
| startIndex | The first index to set. Defaults to zero. | |
| endIndex | The last index to set, plus one. Values that are greater than the number of items in the tuple will be capped to (the number of items in the tuple). Defaults to MUSCLE_NO_LIMIT. |
| uint32 Tuple< NumItems, float >::Replace | ( | const float & | replaceMe, | |
| const float & | withMe, | |||
| uint32 | startIndex = 0, |
|||
| uint32 | endIndex = MUSCLE_NO_LIMIT | |||
| ) | [inline, inherited] |
Replaces all instances of (replaceMe) with (withMe).
| replaceMe | Value to be replaced | |
| withMe | Value to replace instances of (replaceMe) with. | |
| startIndex | The first index to process. Defaults to zero. | |
| endIndex | The last index to process, plus one. Values that are greater than the number of items in the tuple will be capped to (the number of items in the tuple). Defaults to MUSCLE_NO_LIMIT. |
| void Tuple< NumItems, float >::CopySubrange | ( | const Tuple< 4, float > & | rhs, | |
| uint32 | startIndex = 0, |
|||
| uint32 | endIndex = MUSCLE_NO_LIMIT | |||
| ) | [inline, inherited] |
Sets all items in the range [startIndex, endIndex] (inclusive) to be equal to their counterparts in (rhs).
| rhs | The tuple to copy from. | |
| startIndex | The first index to set. Defaults to zero. | |
| endIndex | The last index to set, plus one. Values that are greater than the number of items in the tuple will be capped to (the number of items in the tuple). Defaults to MUSCLE_NO_LIMIT. |
1.5.1