summaryrefslogtreecommitdiff
path: root/src/intersim/module.cpp
blob: e0a228960a2a8eaf4f87b9efd42220ef06099460 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include "booksim.hpp"
#include <iostream>
#include <stdlib.h>

#include "module.hpp"

Module::Module( )
{
}

Module::Module( Module *parent, const string& name )
{
   SetName( parent, name );
}

void Module::_AddChild( Module *child )
{
   _children.push_back( child );
}

void Module::SetName( Module *parent, const string& name )
{
   _name = name;

   if ( parent ) {
      parent->_AddChild( this );
      _fullname = parent->_fullname + "/" + name;
   } else {
      _fullname = name;
   }
}

void Module::DisplayHierarchy( int level ) const
{
   vector<Module *>::const_iterator mod_iter;

   for ( int l = 0; l < level; l++ ) {
      cout << "  ";  
   }

   cout << _name << endl;

   for ( mod_iter = _children.begin( );
       mod_iter != _children.end( ); mod_iter++ ) {
      (*mod_iter)->DisplayHierarchy( level + 1 );
   }
}

void Module::Error( const string& msg ) const
{
   cout << "Error in " << _fullname << " : " << msg << endl;
   exit( -1 );
}

void Module::Debug( const string& msg ) const
{
   cout << "Debug (" << _fullname << ") : " << msg << endl;
}

void Module::Display( ) const 
{
   cout << "Display method not implemented for " << _fullname << endl;
}