CFEL - ASG Software Suite  2.5.0
CASS
Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
cass::CachedList Class Reference

a list of results for caching More...

#include <cached_list.hpp>

+ Collaboration diagram for cass::CachedList:

Classes

struct  item_info
 bundeling the lock status and the id More...
 

Public Types

typedef Result< float > item_type
 define the type of which the list is for More...
 
typedef std::tr1::shared_ptr< item_typeitem_sp
 define a shared pointer of the item More...
 
typedef CASSEvent::id_t id_type
 define the type of the id used More...
 
typedef std::pair< item_info, item_spentry_type
 define an entry in the list More...
 
typedef std::vector< entry_typelist_type
 define the container of items with their ids More...
 
typedef list_type::iterator iter_type
 define an iterator for the list More...
 

Public Member Functions

const item_typeitem (const id_type &id)
 retrieve an item with the right id More...
 
const item_typelatest () const
 retrieve the latest item More...
 
item_typelatest ()
 retrieve the latest item More...
 
void latest (const iter_type it)
 set which one is the latest item More...
 
void release (const id_type &id)
 unlock the item with id More...
 
iter_type newItem (const id_type &id)
 get an item for processing More...
 
void setup (item_sp item, size_t size)
 create the list of items More...
 
void clearItems ()
 clear the items in the list More...
 

Private Member Functions

iter_type findId (const id_type &id)
 get an iterator to the item for id More...
 

Private Attributes

list_type _list
 the list More...
 
QMutex _mutex
 mutex for locking the internal list More...
 
iter_type _latest
 iterator to the latest entry More...
 
iter_type _current
 iterator the currently used entry More...
 

Detailed Description

a list of results for caching

Todo:
make item_type and id_type template parameters
Author
Lutz Foucar

Definition at line 34 of file cached_list.hpp.

Member Typedef Documentation

define an entry in the list

Definition at line 50 of file cached_list.hpp.

define the type of the id used

Definition at line 44 of file cached_list.hpp.

typedef std::tr1::shared_ptr<item_type> cass::CachedList::item_sp

define a shared pointer of the item

Definition at line 41 of file cached_list.hpp.

define the type of which the list is for

Definition at line 38 of file cached_list.hpp.

typedef list_type::iterator cass::CachedList::iter_type

define an iterator for the list

Definition at line 56 of file cached_list.hpp.

define the container of items with their ids

Definition at line 53 of file cached_list.hpp.

Member Function Documentation

void cass::CachedList::clearItems ( )
inline

clear the items in the list

lock and go through all items, lock them and clear them. After they have been cleard unlock them again.

Definition at line 161 of file cached_list.hpp.

References _list, and _mutex.

Referenced by cass::Processor::clearHistograms().

iter_type cass::CachedList::findId ( const id_type id)
inlineprivate

get an iterator to the item for id

Parameters
idthe id for which the entry should be returned

Definition at line 178 of file cached_list.hpp.

References _list, and cass::CachedList::item_info::id.

Referenced by item(), and release().

const item_type& cass::CachedList::item ( const id_type id)
inline

retrieve an item with the right id

Parameters
id

Definition at line 62 of file cached_list.hpp.

References _latest, _list, _mutex, and findId().

Referenced by cass::Processor::result().

const item_type& cass::CachedList::latest ( ) const
inline

retrieve the latest item

Returns
the latest item

Definition at line 75 of file cached_list.hpp.

References _latest.

Referenced by cass::Processor::processEvent(), cass::pp14::processEvent(), and cass::Processor::result().

item_type& cass::CachedList::latest ( )
inline

retrieve the latest item

Returns
the latest item

Definition at line 84 of file cached_list.hpp.

References _latest.

void cass::CachedList::latest ( const iter_type  it)
inline

set which one is the latest item

change the lock of the item from write lock to read lock

Parameters
itpointer to the item to be set as latest

Definition at line 95 of file cached_list.hpp.

References _latest, and _mutex.

iter_type cass::CachedList::newItem ( const id_type id)
inline

get an item for processing

find the next item in the list that has the eventid not set (e.g.: id is 0) Set the id to the event id and return the iterator pointing to the entry.

Clear the item before return it

Returns
iterator to the entry that will be allocated for the id
Parameters
idthe id that the item will have in the list

Definition at line 123 of file cached_list.hpp.

References _current, _latest, _list, and _mutex.

Referenced by cass::Processor::processEvent(), and cass::pp14::processEvent().

void cass::CachedList::release ( const id_type id)
inline

unlock the item with id

make the entry available again by setting the id to 0

Parameters
idthe id of the item to be released

Definition at line 107 of file cached_list.hpp.

References _mutex, and findId().

Referenced by cass::Processor::releaseEvent().

void cass::CachedList::setup ( item_sp  item,
size_t  size 
)
inline

create the list of items

Parameters
itemthe template of which copies will be placed in the container
sizethe number of items that should be in the container

Definition at line 144 of file cached_list.hpp.

References _current, _latest, _list, _mutex, cass::CachedList::item_info::id, info, cass::CachedList::item_info::locked, and size.

Referenced by cass::Processor::createHistList().

Member Data Documentation

iter_type cass::CachedList::_current
private

iterator the currently used entry

Definition at line 202 of file cached_list.hpp.

Referenced by newItem(), and setup().

iter_type cass::CachedList::_latest
private

iterator to the latest entry

Definition at line 199 of file cached_list.hpp.

Referenced by item(), latest(), newItem(), and setup().

list_type cass::CachedList::_list
private

the list

Definition at line 193 of file cached_list.hpp.

Referenced by clearItems(), findId(), item(), newItem(), and setup().

QMutex cass::CachedList::_mutex
private

mutex for locking the internal list

Definition at line 196 of file cached_list.hpp.

Referenced by clearItems(), item(), latest(), newItem(), release(), and setup().


The documentation for this class was generated from the following file: