structures::amorph< contents > Class Template Reference

#include <amorph.h>

Inheritance diagram for structures::amorph< contents >:
Inheritance graph
[legend]
Collaboration diagram for structures::amorph< contents >:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 amorph (int elements=0)
 constructs an amorph capable of holding "elements" pointers.
 ~amorph ()
int elements () const
 the maximum number of elements currently allowed in this amorph.
int valid_fields () const
 Returns the number of fields that have non-NIL contents.
void adjust (int new_max)
 Changes the maximum number of elements for this amorph.
void reset (int new_maximum=0)
 like adjust but doesn't keep existing contents.
basis::outcome put (int field, const contents *data)
 Enters an object into the field at index "field" in the amorph.
basis::outcome append (const contents *data)
 puts "data" on the end of this amorph.
basis::outcome operator+= (const contents *data)
 a synonym for append.
const contents * get (int field) const
 Returns a constant pointer to the information at the index "field".
contents * borrow (int field)
 Returns a pointer to the information at the index "field".
const contents * operator[] (int field) const
 synonym for get.
contents * operator[] (int field)
 synonym for borrow.
contents * acquire (int field)
 Retrieves a "field" from the amorph, taking responsibility for it back.
basis::outcome clear (int field)
 Clears the contents of the field specified.
void clear_all ()
 Clears every field in the amorph.
basis::outcome zap (int start, int end)
 Removes a range of indices from the amorph.
basis::outcome insert (int position, int lines_to_add)
 Adds "lines_to_add" indices to the amorph at the index "position".
int find_empty (basis::outcome &o) const
 Returns the index of a free field if there are any.
const contents * next_valid (int &field) const
 Returns the contents of the next valid element at or after "field".
int find (const contents *to_locate, basis::outcome &o)
 Searches the amorph for the contents specified.
void swap_contents (amorph< contents > &other)
 Exchanges the contents of "this" and "other".

Detailed Description

template<class contents>
class structures::amorph< contents >

Definition at line 22 of file amorph.h.


Constructor & Destructor Documentation

template<class contents >
structures::amorph< contents >::amorph ( int  elements = 0  )  [inline]

constructs an amorph capable of holding "elements" pointers.

Definition at line 208 of file amorph.h.

template<class contents >
structures::amorph< contents >::~amorph (  )  [inline]

Definition at line 219 of file amorph.h.


Member Function Documentation

template<class contents >
contents * structures::amorph< contents >::acquire ( int  field  )  [inline]

Retrieves a "field" from the amorph, taking responsibility for it back.

This function is similar to get, except that the contents are pulled out of the amorph. The contents will no longer be destroyed when the amorph is destroyed. To store the modified contents again, use put, and then the amorph will take over management of the contents again. Note that the index is not zapped with this function; the acquired "field" will simply hold a null pointer.

Definition at line 380 of file amorph.h.

References AMO_ALERT, CHECK_FIELDS, structures::amorph< contents >::elements(), and FUNCDEF.

template<class contents >
void structures::amorph< contents >::adjust ( int  new_max  )  [inline]

Changes the maximum number of elements for this amorph.

If the new number is smaller than the original, then the fields at index "new_maximum" and upwards are thrown away. existing fields are kept.

Definition at line 282 of file amorph.h.

References CHECK_FIELDS, structures::amorph< contents >::clear_all(), and FUNCDEF.

template<class contents>
basis::outcome structures::amorph< contents >::append ( const contents *  data  )  [inline]

puts "data" on the end of this amorph.

adds an element to the end of the amorph by increasing the amorph size (with "adjust") and putting the element into the new spot (with "put").

Definition at line 264 of file amorph.h.

References NIL.

Referenced by octopi::entity_data_bin::acquire_for_entity().

template<class contents >
contents * structures::amorph< contents >::borrow ( int  field  )  [inline]

Returns a pointer to the information at the index "field".

Also returns NIL for invalid indexes. DO NOT destroy the returned pointer; it is still owned by the amorph.

Definition at line 409 of file amorph.h.

References CHECK_FIELDS, FUNCDEF, NIL, and structures::amorph< contents >::put().

Referenced by synchronic::list_manager::clean(), and synchronic::list_manager::update().

template<class contents >
basis::outcome structures::amorph< contents >::clear ( int  field  )  [inline]

Clears the contents of the field specified.

Clearing an empty field has no effect. Clearing an invalid field has no effect. NOTE: clearing the contents means that the contents are destroyed, not just disconnected.

Definition at line 372 of file amorph.h.

template<class contents >
void structures::amorph< contents >::clear_all (  )  [inline]

Clears every field in the amorph.

Definition at line 256 of file amorph.h.

References CHECK_FIELDS, and FUNCDEF.

Referenced by structures::amorph< contents >::adjust().

template<class contents>
int structures::amorph< contents >::elements (  )  const [inline]
template<class contents>
int structures::amorph< contents >::find ( const contents *  to_locate,
basis::outcome o 
) [inline]

Searches the amorph for the contents specified.

Since only pointers to the contents are maintained, the search is based on finding a pointer in the amorph that is identical to "to_locate". if "o" is OKAY, then the index of the entry is returned. If "o" is NOT_FOUND, then the contents are not present.

Definition at line 393 of file amorph.h.

References bounds_return, CHECK_FIELDS, structures::amorph< contents >::elements(), FUNCDEF, structures::amorph< contents >::get(), and NIL.

template<class contents >
int structures::amorph< contents >::find_empty ( basis::outcome o  )  const [inline]

Returns the index of a free field if there are any.

The returned index is invalid if the "o" is IS_FULL.

Definition at line 346 of file amorph.h.

template<class contents >
const contents * structures::amorph< contents >::get ( int  field  )  const [inline]

Returns a constant pointer to the information at the index "field".

If no information is stored or the field is out range, then NIL is returned.

Reimplemented from basis::array< contents * >.

Definition at line 273 of file amorph.h.

Referenced by structures::amorph_assign(), filesystem::heavy_file_operations::buffer_files(), synchronic::list_manager::clone_object(), structures::amorph< contents >::find(), filesystem::filename_list::operator=(), and synchronic::list_manager::retrieve().

template<class contents >
basis::outcome structures::amorph< contents >::insert ( int  position,
int  lines_to_add 
) [inline]

Adds "lines_to_add" indices to the amorph at the index "position".

If "lines_to_add" is non-positive, the request is ignored. Inserting at a position beyond the bounds of the array is ignored, but a position AT elements() is allowed (it is an append...).

Reimplemented from basis::array< contents * >.

Definition at line 306 of file amorph.h.

template<class contents >
const contents * structures::amorph< contents >::next_valid ( int &  field  )  const [inline]

Returns the contents of the next valid element at or after "field".

"field" is set to the location where an entry was found, if one was actually found. If none exists at "field" or after it, then NIL is returned.

Definition at line 358 of file amorph.h.

template<class contents>
basis::outcome structures::amorph< contents >::operator+= ( const contents *  data  )  [inline]

a synonym for append.

Definition at line 54 of file amorph.h.

template<class contents>
contents* structures::amorph< contents >::operator[] ( int  field  )  [inline]

synonym for borrow.

Reimplemented from basis::array< contents * >.

Definition at line 69 of file amorph.h.

template<class contents>
const contents* structures::amorph< contents >::operator[] ( int  field  )  const [inline]

synonym for get.

Reimplemented from basis::array< contents * >.

Definition at line 67 of file amorph.h.

template<class contents>
basis::outcome structures::amorph< contents >::put ( int  field,
const contents *  data 
) [inline]

Enters an object into the field at index "field" in the amorph.

If "data" is NIL, then the field is cleared. The amorph considers the pointer "data" to be its own property after put is invoked; "data" should not be destructed since the amorph will automatically do so. This restriction does not hold if the object is checked back out of the amorph with acquire().

Definition at line 331 of file amorph.h.

Referenced by structures::amorph< contents >::borrow().

template<class contents >
void structures::amorph< contents >::reset ( int  new_maximum = 0  )  [inline]
template<class contents>
void structures::amorph< contents >::swap_contents ( amorph< contents > &  other  )  [inline]

Exchanges the contents of "this" and "other".

No validation is performed but this should always succeed given amorphs that are constructed properly.

Definition at line 418 of file amorph.h.

template<class contents>
int structures::amorph< contents >::valid_fields (  )  const [inline]

Returns the number of fields that have non-NIL contents.

This might be different from the number of total elements.

Definition at line 29 of file amorph.h.

template<class contents >
basis::outcome structures::amorph< contents >::zap ( int  start,
int  end 
) [inline]

Removes a range of indices from the amorph.

This does not just clear the field associated with the specified index as "clear" does, it actually changes the number of total elements by removing the indices from the amorph. The new amorph contains the old elements up to just before the "start" and from the "end" + 1 through the end of the amorph. AMORPH_BAD_INDEX is returned if either index is out of range. If the zap succeeds, then AMORPH_OKAY is returned, even if the "end" is less than the "start".

Reimplemented from basis::array< contents * >.

Definition at line 318 of file amorph.h.

References CHECK_FIELDS, structures::amorph< contents >::elements(), and FUNCDEF.

Referenced by synchronic::list_manager::clean(), filesystem::directory_tree::remove_path(), synchronic::list_manager::reset(), and synchronic::list_manager::zap().


The documentation for this class was generated from the following file:
Generated on Sat Jan 28 04:25:55 2012 for hoople2 project by  doxygen 1.6.3