`timescale 1ns/1ps
`include "uvm_macros.svh"
import uvm_pkg::*;

class utility_catcher extends uvm_report_catcher;
  int calls;
  function new(string name="utility_catcher"); super.new(name); endfunction
  function action_e catch();
    if (get_id() == "CALLBACK_PROBE") calls++;
    return THROW;
  endfunction
endclass

module utility_probe;
  initial begin
    uvm_tlm_transport_channel#(int,int) channel_value = new("channel_value", null);
    uvm_int_rsrc resource_value = new("specialized", "scope");
    uvm_resource#(int) found;
    uvm_report_object reporter = new("reporter");
    utility_catcher shared = new(), local_value = new("local_value");
    uvm_report_catcher all_callbacks[$];
    uvm_parent_child_link link_value;
    uvm_sequence_item a = new("a"), b = new("b");
    process self_process;
    string before_state;
    int result;
    $display("REVIEW|transport_type_name|%s", channel_value.get_type_name());
    found = uvm_resource_db#(int)::get_by_name("scope", "specialized", 0);
    $display("REVIEW|specialized_constructor_in_pool|%0d", found != null);
    if ($test$plusargs("MIGRATED")) begin
      uvm_report_cb::add(reporter, local_value);
      uvm_report_cb::add(null, shared);
    end
    else begin
      uvm_report_cb::add(null, shared);
      uvm_report_cb::add(reporter, local_value);
    end
    reporter.uvm_report_info("CALLBACK_PROBE", "callback observation", UVM_NONE);
    $display("REVIEW|global_callback_calls|%0d", shared.calls);
    $display("REVIEW|local_callback_calls|%0d", local_value.calls);
`ifdef REVIEW_UVM20
    uvm_report_cb::get_all(all_callbacks, reporter);
    uvm_report_cb::get_all(all_callbacks, reporter);
    $display("REVIEW|get_all_appends|%0d", all_callbacks.size());
`endif
    self_process = process::self();
    before_state = self_process.get_randstate();
    link_value = uvm_parent_child_link::get_link(a,b);
    $display("REVIEW|link_preserves_randstate|%0d", before_state == self_process.get_randstate());
    // The same expression has different regex/glob meaning.
    result = uvm_re_match("a.*", "abc");
    $display("REVIEW|direct_regex_match|%0d", result == 0);
    $display("REVIEW|glob_after_regex|%0d", uvm_is_match("a.*", "abc"));
    $display("REVIEW|done|1");
    $finish;
  end
endmodule
