Static property question

Ive got an agent with static integer. This indicates how many agents of this type have been created.

class my_agent extends uvm_component;

  static integer count=0;

  function new( string name = "", uvm_component parent = null );
    super.new( name, parent );
    count++;
  endfunction

  //...

endclass

Consider I’ve got a subsystem environment with two identical sub-environments, each of which create an different sized array of these agents.

I want the static property to indicate the number of agents created, but ONLY for the environment in which it lies.

In reply to bmorris:
If the parent of the agent is the env, you can do

class my_agent extends uvm_component;

  static integer count[uvm_component] = '{default:0};

  function new( string name = "", uvm_component parent = null );
    super.new( name, parent );
    count[parent]++;
  endfunction

  //...

endclass




In reply to dave_59:

Yes, works well, I was close; I used string instead of uvm_component.
One small typo:
static integer cnt[uvm_component] = '{default:0};

So, where is m_parent documented?? I have never seen before, but it works.

In reply to bmorris:

I should have use get_parent(). but parent will work too. corrected.