TLM-2.0: include/tlm/tlm_1/tlm_analysis/tlm_analysis_port.h Source File

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

# include/tlm/tlm_1/tlm_analysis/tlm_analysis_port.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_ANALYSIS_PORT_H__
    00019 #define __TLM_ANALYSIS_PORT_H__
    00020
    00021 #include "tlm_analysis_if.h"
    00022 #include <deque>
    00023
    00024 namespace tlm {
    00025
    00026
    00027 template < typename T>
    00028 class tlm_analysis_port :
    00029   public sc_core::sc_object ,
    00030   public virtual tlm_analysis_if< T >
    00031 {
    00032  public:
    00033   tlm_analysis_port() : sc_core::sc_object() {}
    00034   tlm_analysis_port( const char *nm ) : sc_core::sc_object( nm ) {}
    00035
    00036   // bind and () work for both interfaces and analysis ports, since
    00037   // analysis ports implement the analysis interface
    00038
    00039   void bind( tlm_analysis_if<T> &_if ) {
    00040     m_interfaces.push_back( &_if );
    00041   }
    00042
    00043   void operator() ( tlm_analysis_if<T> &_if ) { bind( _if ); }
    00044
    00045   bool unbind( tlm_analysis_if<T> &_if ) {
    00046
    00047     typename std::deque< tlm_analysis_if<T> *>::iterator i;
    00048
    00049     for( i = m_interfaces.begin();
    00050          i != m_interfaces.end();
    00051          i++ ) {
    00052
    00053       if( *i == &_if ) {
    00054
    00055         m_interfaces.erase( i );
    00056         return 1;
    00057
    00058       }
    00059
    00060     }
    00061
    00062     return 0;
    00063
    00064   }
    00065
    00066   void write( const T &t ) {
    00067     typename std::deque< tlm_analysis_if<T> * >::iterator i;
    00068
    00069     for( i = m_interfaces.begin();
    00070          i != m_interfaces.end();
    00071          i++ ) {
    00072
    00073       (*i)->write( t );
    00074
    00075     }
    00076
    00077   }
    00078
    00079  private:
    00080   std::deque< tlm_analysis_if<T> * > m_interfaces;
    00081
    00082 };
    00083
    00084 } // namespace tlm
    00085
    00086 #endif
    00087
    00088