<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def trace_class(cls, tracer=tracer, pattern=r".*", flags=0):
 """ Traces given class using given tracer. :param cls: Class to trace. :type cls: object :param tracer: Tracer. :type tracer: object :param pattern: Matching pattern. :type pattern: unicode :param flags: Matching regex flags. :type flags: int :return: Definition success. :rtype: bool """


    if not is_base_traced(cls) and (is_traced(cls) or is_read_only(cls)):
        return False

    for name, method in inspect.getmembers(cls, inspect.ismethod):
        if not re.search(pattern, name, flags=flags):
            continue

        trace_method(cls, method, tracer)

    for name, function in inspect.getmembers(cls, inspect.isfunction):
        if not re.search(pattern, name, flags=flags):
            continue

        trace_method(cls, function, tracer)

    for name, accessor in inspect.getmembers(cls, lambda x: type(x) is property):
        if not re.search(pattern, name, flags=flags):
            continue

        trace_property(cls, accessor, tracer)

    set_traced(cls)

    return True