Can we have a general function of any function this way?
The function you are describing is known as a universal Turing machine. A universal Turing machine is given a Turing machine $T$ and an input $x$, and outputs $T(x)$ (if $T$ doesn't halt, the universal Turing machine also doesn't halt).

If you want your function to have restricted complexity, you can just stop the computation once it has gone on for too long, and output zero, say. For any Turing machine with the correct complexity, the restricted universal Turing machine will still be correct. A variant is to accept a clocked Turing machine, which provides its own bound on the running time (which you can choose to ignore at your discretion).