Sitemap | Search || Zen Spider Website
/ Satori
/ Satori Class Index
/ Class Pointer
Class Pointer
-

|
- template class
-
- Pointer< class Type >
-
|
- Programmer: Ryan Davis
|
-
- Description:
- Provides a safe pointer of any type. It will not
- allow you to dereference the pointer if the
- address of the pointer is NULL. It will allow you
- only to do "pointerish" things with it such as
- *, ->, or == but not + or other possibly dangerous
- (and not protectable) things...
-
-
- Public Methods:
-
-
-
- Pointer
- (Type * pointee = NULL);
- This is the constructor. It has a default value of NULL, so it can
- be used as the generic constructor as well. This constructor
- creates a smart Pointer object that points to the address
- passed in through .
-
-
-
-
- Pointer
- (const Pointer<Type> &);
- This is the copy constructor. It allows us to specify exactly what
- happens during a copy of a Pointer object. This isn't entirely
- necessary because our object is simple, but it is probably better
- to be explicitly obvious rather than not.
-
-
-
-
- ~Pointer
- ();
- This is the destructor. It doesn't do a thing. This is because the
- Pointer object never allocates memory, it just points...
-
-
- Pointer<Type> &
-
- operator =
- (const Pointer<Type> & pointee);
- This is the assignment operator. Not really needed since Pointer's
- don't have responsibility over what they point to (they don't // allocate or destroy memory), but it is my opinion that it is better
- to be explicit rather than suprised. This simply assigns the address
- of pointee to this.
-
-
- Pointer<Type> &
-
- operator =
- (Type * pointee);
- This is another assignment operator. This one is much like the
- previous, except that it allows to assign from a low level pointer,
- bypassing an invisible Construction/Copy/Destruction phase.
-
-
- Type *
-
- asPointer
- ();
- This conversion operator can change a high level pointer (our // object) to a low level pointer.
-
-
- Type &
-
- operator *
- ();
- This operator validates myData to make sure it is not NULL. Then
- returns a refernce to the object pointed to.
-
-
- Type *
-
- operator ->
- ();
- This operator validates myData to make sure myData is not NULL. It
- then returns a pointer to the object pointed to.
- WARNING: If you get a compile error, you are using a low level type.
- You can NOT use a low level type with this class, because -> is
- an illegal concept for low level types:
- int a = 42, *b = &a;
- b->???; this doesn't work because b->??? is the same as (*b).???
- and since a low level type is not a struct so '.' doesn't work...
-
-
- Boolean operator
-
- =
- (const Pointer<Type> &);
- This operator compares two addresses to see if they are the same and
- returns a Boolean.
-
-
- Boolean operator
-
- !=
- (const Pointer<Type> &);
- This operator uses the equality operator == as a function, but
- returns the opposite value.
-
-
-
- Protected Methods:
-
- void
-
- validate
- ();
- Validate asserts that the address we point to is not NULL.
-
-
- Protected Members:
-
- Type *
-
- myData;
- myData is the variable we use inside the pointer class. It is a
- a pointer of type Type. It cannot be accessed outside the Pointer
- class because myData is protected.
-
-
-
Sitemap | Search || Zen Spider Website
/ Satori
/ Satori Class Index
/ Class Pointer