| 1 |
/* |
| 2 |
* (C) Copyright 2013 ECMWF. |
| 3 |
* |
| 4 |
* This software is licensed under the terms of the Apache Licence Version 2.0 |
| 5 |
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. |
| 6 |
* In applying this licence, ECMWF does not waive the privileges and immunities |
| 7 |
* granted to it by virtue of its status as an intergovernmental organisation |
| 8 |
* nor does it submit to any jurisdiction. |
| 9 |
*/ |
| 10 |
|
| 11 |
#include "atlas_trace.h" |
| 12 |
|
| 13 |
#include <string> |
| 14 |
#include <vector> |
| 15 |
|
| 16 |
#include "atlas/runtime/Exception.h" |
| 17 |
#include "atlas/runtime/Log.h" |
| 18 |
#include "atlas/runtime/Trace.h" |
| 19 |
#include "atlas/runtime/trace/CodeLocation.h" |
| 20 |
|
| 21 |
namespace atlas { |
| 22 |
|
| 23 |
//static std::vector<std::string> Labels( int size, const char* labels[] ) { |
| 24 |
// std::vector<std::string> _labels; |
| 25 |
// _labels.reserve( size ); |
| 26 |
// for ( int i = 0; i < size; ++i ) { |
| 27 |
// _labels.emplace_back( labels[i] ); |
| 28 |
// } |
| 29 |
// return _labels; |
| 30 |
//} |
| 31 |
|
| 32 |
extern "C" { |
| 33 |
|
| 34 |
Trace* new_atlas_Trace(const char* file, int line, const char* title) { |
| 35 |
return new Trace(CodeLocation(file, line, nullptr, true), std::string(title)); |
| 36 |
} |
| 37 |
|
| 38 |
Trace* new_atlas_Trace_labels_1(const char* file, int line, const char* title, const char* label1) { |
| 39 |
std::vector<std::string> labels{label1}; |
| 40 |
return new Trace(CodeLocation(file, line, nullptr, true), std::string(title), labels); |
| 41 |
} |
| 42 |
Trace* new_atlas_Trace_labels_2(const char* file, int line, const char* title, const char* label1, const char* label2) { |
| 43 |
std::vector<std::string> labels{label1, label2}; |
| 44 |
return new Trace(CodeLocation(file, line, nullptr, true), std::string(title), labels); |
| 45 |
} |
| 46 |
Trace* new_atlas_Trace_labels_3(const char* file, int line, const char* title, const char* label1, const char* label2, |
| 47 |
const char* label3) { |
| 48 |
std::vector<std::string> labels{label1, label2, label3}; |
| 49 |
return new Trace(CodeLocation(file, line, nullptr, true), std::string(title), labels); |
| 50 |
} |
| 51 |
Trace* new_atlas_Trace_labels_4(const char* file, int line, const char* title, const char* label1, const char* label2, |
| 52 |
const char* label3, const char* label4) { |
| 53 |
std::vector<std::string> labels{label1, label2, label3, label4}; |
| 54 |
return new Trace(CodeLocation(file, line, nullptr, true), std::string(title), labels); |
| 55 |
} |
| 56 |
Trace* new_atlas_Trace_labels_5(const char* file, int line, const char* title, const char* label1, const char* label2, |
| 57 |
const char* label3, const char* label4, const char* label5) { |
| 58 |
std::vector<std::string> labels{label1, label2, label3, label4, label5}; |
| 59 |
return new Trace(CodeLocation(file, line, nullptr, true), std::string(title), labels); |
| 60 |
} |
| 61 |
|
| 62 |
void delete_atlas_Trace(Trace* This) { |
| 63 |
ATLAS_ASSERT(This != nullptr, "Cannot delete uninitialised atlas_Trace"); |
| 64 |
delete This; |
| 65 |
This = nullptr; |
| 66 |
} |
| 67 |
|
| 68 |
void atlas_Trace__start(Trace* This) { |
| 69 |
ATLAS_ASSERT(This != nullptr, "Cannot start uninitialised atlas_Trace"); |
| 70 |
This->start(); |
| 71 |
} |
| 72 |
|
| 73 |
void atlas_Trace__stop(Trace* This) { |
| 74 |
ATLAS_ASSERT(This != nullptr, "Cannot stop uninitialised atlas_Trace"); |
| 75 |
This->stop(); |
| 76 |
} |
| 77 |
|
| 78 |
void atlas_Trace__pause(Trace* This) { |
| 79 |
ATLAS_ASSERT(This != nullptr, "Cannot pause uninitialised atlas_Trace"); |
| 80 |
This->pause(); |
| 81 |
} |
| 82 |
|
| 83 |
void atlas_Trace__resume(Trace* This) { |
| 84 |
ATLAS_ASSERT(This != nullptr, "Cannot resume uninitialised atlas_Trace"); |
| 85 |
This->resume(); |
| 86 |
} |
| 87 |
|
| 88 |
int atlas_Trace__running(Trace* This) { |
| 89 |
ATLAS_ASSERT(This != nullptr, "Cannot check 'running' status of uninitialised atlas_Trace"); |
| 90 |
return This->running(); |
| 91 |
} |
| 92 |
|
| 93 |
double atlas_Trace__elapsed(Trace* This) { |
| 94 |
ATLAS_ASSERT(This != nullptr, "Cannot check elapsed time of uninitialised atlas_Trace"); |
| 95 |
return This->elapsed(); |
| 96 |
} |
| 97 |
|
| 98 |
} // extern C |
| 99 |
|
| 100 |
} // namespace atlas |