How to make the code more generic?

I have the following code for passive agent who has only monitor and agent config file:

class tx_upconv_in_agent extends uvm_agent;
   //configuration object
   tx_upconv_in_agent_config m_cfg;
   //factory registration
   `uvm_component_utils(tx_upconv_in_agent)
  
   //external interfaces  
   uvm_analysis_port#(tx_upconv_in_transaction) agent_ap;

   //internal interfaces
   //virtual tx_upconv_in_interface tx_upconv_in_if_i;
   tx_upconv_in_monitor tx_upconv_in_monitor_i;
   
   //constructor
   function new(string name = "tx_upconv_in_agent", uvm_component parent);
      super.new(name, parent);
   endfunction: new

   //build phase
   virtual  function void build_phase(uvm_phase phase);
      if(!uvm_config_db #(tx_upconv_in_agent_config)::get(this, "", "db_tx_upconv_in_agent_config", m_cfg)) begin
	 `uvm_error("build_phase", "agent_config not found")
      end//if

      agent_ap = new(.name("tx_upconv_in_agent_ap"), .parent(this));
      //Monitor is always built
      tx_upconv_in_monitor_i = tx_upconv_in_monitor::type_id::create("tx_upconv_in_monitor_i", this);
   endfunction: build_phase

    //connect phase
   virtual function void connect_phase(uvm_phase phase);
      //Monitor is always connected
      tx_upconv_in_monitor_i.ap.connect(agent_ap);
      tx_upconv_in_monitor_i.vif = m_cfg.tx_upconv_in_vif;      
   endfunction: connect_phase
 
endclass: tx_upconv_in_agent

I have and will have more passive agents similar to this (has only monitor and agent config file), Is there any way to make this code more generic/reusable?

In reply to saritr:

I believe you are looking for the wrong approach. From my professional experience (15+ UVM projects) I know the best solution is to use a UVM Framework generator. Such a geneartor is creating a complete UVM framework in less than half a day. It is compilable and you can start to simulate immidiately. There are commercial tools on the market like vtool, but also tools free of charge like the EasierUVM Framework Generator from Doulos.
Visit Doulos

You could try one of below.

  1. write a macro if all of agent code would be similar.
  2. parameterize class with type and pass correct class type while creating them.

class generic_passive_agent#(type T_TRANS,type T_CFG,type T_MON) extends uvm_agent;
.... 
endclass

class env extends uvm_env;
  generic_passive_agent#(tx_tr,tx_cfg,tx_mon) tx_agent;
  generic_passive_agent#(rx_tr,rx_cfg,rx_mon) rx_agent;
endclass