TLM-2.0: include/tlm/tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/tlm_fifo_peek.h Source File

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

# include/tlm/tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/tlm_fifo_peek.h

Go to the documentation of this file.

    00001 /*****************************************************************************
    00002
    00003   The following code is derived, directly or indirectly, from the SystemC
    00004   source code Copyright (c) 1996-2008 by all Contributors.
    00005   All Rights reserved.
    00006
    00007   The contents of this file are subject to the restrictions and limitations
    00008   set forth in the SystemC Open Source License Version 3.0 (the "License");
    00009   You may not use this file except in compliance with such restrictions and
    00010   limitations. You may obtain instructions on how to receive a copy of the
    00011   License at http://www.systemc.org/. Software distributed by Contributors
    00012   under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
    00013   ANY KIND, either express or implied. See the License for the specific
    00014   language governing rights and limitations under the License.
    00015
    00016  *****************************************************************************/
    00017
    00018 #ifndef __TLM_FIFO_PEEK_H__
    00019 #define __TLM_FIFO_PEEK_H__
    00020
    00021 namespace tlm {
    00022
    00023 template < typename T>
    00024 inline
    00025 T
    00026 tlm_fifo<T>::peek( tlm_tag<T> * ) const {
    00027
    00028   while( is_empty() ) {
    00029
    00030     // this const cast is only needed because sc_prim_channel::wait(.) is
    00031     // for some unknown reason, not const
    00032
    00033     const_cast< tlm_fifo<T> * >( this )->wait( m_data_written_event );
    00034
    00035   }
    00036
    00037   return buffer->read_data();
    00038
    00039 }
    00040
    00041 template < typename T>
    00042 inline
    00043 bool
    00044 tlm_fifo<T>::nb_peek( T &t ) const {
    00045
    00046   if( used() < 1 ) {
    00047     return false;
    00048   }
    00049
    00050   t = buffer->peek_data( 0 );
    00051   return true;
    00052
    00053 }
    00054
    00055 template < typename T>
    00056 inline
    00057 bool
    00058 tlm_fifo<T>::nb_peek( T &t , int n ) const {
    00059
    00060   if( n >= used() || n < -1 ) {
    00061     return false;
    00062   }
    00063
    00064   if( n == -1 ) {
    00065     n = used() - 1;
    00066   }
    00067
    00068   t = buffer->peek_data( n );
    00069   return true;
    00070
    00071 }
    00072
    00073 template< typename T >
    00074 inline
    00075 bool
    00076 tlm_fifo<T>::nb_can_peek( tlm_tag<T> * ) const
    00077 {
    00078   return !is_empty();
    00079 }
    00080
    00081 template < typename T>
    00082 inline
    00083 bool
    00084 tlm_fifo<T>::nb_poke( const T &t , int n ) {
    00085
    00086   if( n >= used() || n < 0 ) {
    00087     return false;
    00088   }
    00089
    00090   buffer->poke_data( n ) = t;
    00091   return true;
    00092
    00093 }
    00094
    00095 } // namespace tlm
    00096
    00097 #endif