Test examples, why 'double' config objects for nested ones?

Many of the examples I see related to configuration follow the following pattern:


class ... 

//------------------------------------------
// Component Members
//------------------------------------------
// The environment class
spi_env m_env;
// Configuration objects
spi_env_config m_env_cfg;   // inside has agent handles
apb_agent_config m_apb_cfg;
spi_agent_config m_spi_cfg;
// Register map
spi_register_map spi_rm;
 
...
 
endclass: spi_test_base
 

// Build the env, create the env configuration
// including any sub configurations and assigning virtural interfaces
function void spi_test_base::build_phase( uvm_phase phase );
 m_env_cfg = spi_env_config::type_id::create("m_env_cfg");

 // Register map - Keep reg_map a generic name for vertical reuse reasons
 spi_rm = new("reg_map", null);
 m_env_cfg.spi_rm = spi_rm;

 m_apb_cfg = apb_agent_config::type_id::create("m_apb_cfg");
 configure_apb_agent(m_apb_cfg);
 if( !uvm_config_db #(virtual apb_if)::get(this, "" , "APB_vif",m_apb_cfg.APB) ) `uvm_error(...)
 m_env_cfg.m_apb_agent_cfg = m_apb_cfg;


Why does the class have member handles for the (nested) env config AND configs for each of the agents IN the env?

What is wrong with:


class ... 

//------------------------------------------
// Component Members
//------------------------------------------
// The environment class
spi_env m_env;
// Configuration objects
spi_env_config m_env_cfg;   // inside has agent handles

...
 
endclass: spi_test_base
 

// Build the env, create the env configuration
// including any sub configurations and assigning virtural interfaces
function void spi_test_base::build_phase( uvm_phase phase );

 apb_agent_config m_apb_cfg;
 spi_agent_config m_spi_cfg;

 m_env_cfg = spi_env_config::type_id::create("m_env_cfg");

 // Register map - Keep reg_map a generic name for vertical reuse reasons
 m_env_cfg.spi_rm = new("reg_map", null);

 m_apb_cfg = apb_agent_config::type_id::create("m_apb_cfg");
 configure_apb_agent(m_apb_cfg);
 if( !uvm_config_db #(virtual apb_if)::get(this, "" , "APB_vif",m_apb_cfg.APB) ) `uvm_error(...)
 m_env_cfg.m_apb_agent_cfg = m_apb_cfg;


It just always confuses me to see 2 members that in my opinion are identical for the test: m_env_cfg.m_apb_agent_cfg and m_apb_cfg

Note: I am ok with the env then creating seperate config objects, it is just in the test example that the confusion arises.

In reply to NiLu:

You are adressing convinience functions. We are using on the one hand nested config objects and non-nested config objects.
Both have the same value. There is no difference.
If we are using both handles we have somewhere an assignment like this:
m_apb_cfg = m_env_cfg.m_apb_agent_cfg. This might be used for a set command in this component.
Finally it is a question of taste. There is no need to have both types of handles available.