@@ -11,7 +11,9 @@ const char *wrapperFileClass = "wrapper.class";
1111const char *WrapperFile = " wrapper" ;
1212const char *WrapperClass = " Wrapper" ;
1313const char *PythonSo = " libpython3.so" ;
14+
1415wrapperMeterCustom g_metric_cb;
16+ wrapperTraceLog g_trace_cb;
1517
1618std::mutex RECORD_MUTEX;
1719std::map <std::string, std::string> SID_RECORD;
@@ -20,6 +22,7 @@ std::map<std::string, const char *> SID_USRTAG;
2022
2123PYBIND11_EMBEDDED_MODULE (aiges_embed, module ) {
2224 module .def (" callback_metric" , &callbackMetric, py::return_value_policy::automatic_reference);
25+ module .def (" callback_trace" , &callbackT, py::return_value_policy::automatic_reference);
2326 module .def (" callback" , &callBack, py::return_value_policy::automatic_reference);
2427 py::class_<ResponseData> responseData (module , " ResponseData" );
2528 responseData.def (py::init<>())
@@ -371,13 +374,20 @@ std::string PyWrapper::wrapperError(int err) {
371374
372375}
373376
374- int PyWrapper::wrapperSetCtrl (CtrlType type, wrapperMeterCustom mc) {
377+ int PyWrapper::wrapperSetMetricFunc (CtrlType type, wrapperMeterCustom mc) {
375378 if (type == CTMeterCustom) {
376379 g_metric_cb = mc;
377380 }
378381 return 0 ;
379382}
380383
384+ int PyWrapper::wrapperSetTraceFunc (CtrlType type, wrapperTraceLog mc) {
385+ if (type == CTTraceLog) {
386+ g_trace_cb = mc;
387+ }
388+ return 0 ;
389+ }
390+
381391std::string
382392PyWrapper::wrapperCreate (const char *usrTag, std::map <std::string, std::string> params, wrapperCallback cb,
383393 int *errNum, std::string sid) {
@@ -546,10 +556,15 @@ int PyWrapper::wrapperTest() {
546556}
547557
548558int callbackMetric (const char *usrTag, const char *meterKey, int count) {
549- printf (" %s, %s, %d\n " , usrTag, meterKey, count);
559+ printf (" callback Metric: %s, %s, %d\n " , usrTag, meterKey, count);
550560 return g_metric_cb (usrTag, meterKey, count);
551561}
552562
563+ int callbackTrace (const char *usrTag, const char *key, const char *value) {
564+ printf (" callback Trace: %s, %s, %d\n " , usrTag, key, value);
565+ return g_trace_cb (usrTag, key, value);
566+ }
567+
553568int callBack (Response *resp, std::string sid) {
554569 wrapperCallback cb_;
555570 cb_ = GetSidCB (sid);
@@ -648,8 +663,8 @@ const std::string GetSidByUsrTag(const char *usrTag) {
648663 RECORD_MUTEX.lock ();
649664 // 通过value找 key
650665 for (std::map<std::string, const char *>::iterator it = SID_USRTAG.begin (); it != SID_USRTAG.end (); it++) {
651- if (it->second == usrTag){
652- RECORD_MUTEX.unlock ();
666+ if (it->second == usrTag) {
667+ RECORD_MUTEX.unlock ();
653668 return it->first ;
654669
655670 }
0 commit comments