Sync with 5.3.0
[deliverable/titan.core.git] / core / TCov.hh
1 ///////////////////////////////////////////////////////////////////////////////
2 // Copyright (c) 2000-2014 Ericsson Telecom AB
3 // All rights reserved. This program and the accompanying materials
4 // are made available under the terms of the Eclipse Public License v1.0
5 // which accompanies this distribution, and is available at
6 // http://www.eclipse.org/legal/epl-v10.html
7 ///////////////////////////////////////////////////////////////////////////////
8 #ifndef TCOV_HH
9 #define TCOV_HH
10
11 #include <sys/types.h> // for pid_t
12 #include "memory.h"
13 #include "Types.h" // for boolean
14
15 #include "Vector.hh"
16
17 class FunctionData
18 {
19 public:
20 explicit FunctionData(const char *name = NULL, int pos = 0, int count = 0)
21 : m_pos(pos), m_count(count) { if (name != NULL) m_name = mcopystr(name); }
22 ~FunctionData() { Free(m_name); }
23 inline const char *get_name() const { return m_name; }
24 inline int get_pos() const { return m_pos; }
25 inline int get_count() const { return m_count; }
26 inline void reset() { m_count = 0; }
27 FunctionData& operator++() { ++m_count; return *this; }
28 private:
29 /// Copy constructor disabled
30 FunctionData(const FunctionData&);
31 /// %Assignment disabled
32 FunctionData& operator=(const FunctionData&);
33 char *m_name;
34 int m_pos; // For later improvement.
35 int m_count;
36 };
37
38 class LineData
39 {
40 public:
41 explicit LineData(int no = 0, int count = 0): m_no(no), m_count(count) { }
42 inline int get_no() const { return m_no; }
43 inline int get_count() const { return m_count; }
44 inline void reset() { m_count = 0; }
45 LineData& operator++() { ++m_count; return *this; }
46 private:
47 /// Copy constructor disabled
48 LineData(const LineData&);
49 /// %Assignment disabled
50 LineData& operator=(const LineData&);
51 int m_no;
52 int m_count;
53 };
54
55 class FileData
56 {
57 public:
58 explicit FileData(const char *file_name);
59 ~FileData();
60 inline const char *get_file_name() const { return m_file_name; }
61 inline const Vector<FunctionData *>& get_function_data() const { return m_function_data; }
62 inline const Vector<LineData *>& get_line_data() const { return m_line_data; }
63 void inc_function(const char *function_name, int line_no);
64 void inc_line(int line_no);
65 void init_function(const char *function_name);
66 void init_line(int line_no);
67 size_t has_line_no(int line_no);
68 size_t has_function_name(const char *function_name);
69 void reset();
70 private:
71 /// Copy constructor disabled
72 FileData(const FileData&);
73 /// %Assignment disabled
74 FileData& operator=(const FileData&);
75 char *m_file_name;
76 Vector<FunctionData *> m_function_data;
77 Vector<LineData *> m_line_data;
78 };
79
80 // We all belong to the _same_ component.
81 class TCov
82 {
83 public:
84 static void hit(const char *file_name, int line_no, const char *function_name = NULL);
85 static void init_file_lines(const char *file_name, const int line_nos[], size_t line_nos_len);
86 static void init_file_functions(const char *file_name, const char *function_names[], size_t function_names_len);
87 static expstring_t comp(boolean withname = FALSE);
88 static void close_file();
89 private:
90 /// Copy constructor disabled
91 TCov(const TCov& tcov);
92 /// %Assignment disabled
93 TCov& operator=(const TCov& tcov);
94 static size_t has_file_name(const char *file_name);
95 static void pid_check();
96
97 static Vector<FileData *> m_file_data;
98 static pid_t mypid;
99 static expstring_t mycomp;
100 static expstring_t mycomp_name;
101 static int ver_major;
102 static int ver_minor;
103 };
104
105 #endif // TCOV_HH
This page took 0.036675 seconds and 5 git commands to generate.