小编Gáb*_*ics的帖子

如何构建特定函数调用的图表?

我有一个项目,我想动态构建特定函数调用的图表。例如,如果我有 2 个模板类 A 和 B,其中 A 有一个跟踪方法(保存为图形节点),B 有 3 个方法(非跟踪方法、跟踪方法和调用 A 的跟踪方法的跟踪方法),那么我希望能够仅将跟踪的方法调用注册为图形对象作为节点。图形对象可以是单例。

template <class TA>
class A
{
public:
    void runTracked()
    {
        // do stuff
    }
};

template <class TB>
class B
{
public:
    void runNonTracked()
    {
        // do stuff
    }

    void runTracked()
    {
        // do stuff
    }

    void callATracked()
    {
        auto a = A<TB>();
        a.runTracked();
        // do stuff
    }
};

void root()
{
    auto b1 = B<int>();
    auto b2 = B<double>();
    b1.runTracked();
    b2.runNonTracked();
    b2.callATracked();
    
}

int main()
{ …
Run Code Online (Sandbox Code Playgroud)

c++ trace templates c++11 runtime-configuration

6
推荐指数
1
解决办法
444
查看次数

标签 统计

c++ ×1

c++11 ×1

runtime-configuration ×1

templates ×1

trace ×1