File: jnimw.h

package info (click to toggle)
eclipse-titan 6.5.0-1
  • links: PTS
  • area: main
  • in suites: buster
  • size: 101,128 kB
  • sloc: cpp: 259,139; ansic: 47,560; yacc: 22,554; makefile: 14,074; sh: 12,630; lex: 9,101; xml: 5,362; java: 4,849; perl: 3,784; awk: 48; php: 32; python: 13
file content (97 lines) | stat: -rw-r--r-- 2,547 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/******************************************************************************
 * Copyright (c) 2000-2018 Ericsson Telecom AB
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
 *
 * Contributors:
 *   Balasko, Jeno
 *   Lovassy, Arpad
 *
 ******************************************************************************/
#ifndef JNIMW_JNIMW_H
#define JNIMW_JNIMW_H
//----------------------------------------------------------------------------

#include <stdio.h>
#include <pthread.h>
#include <jni.h>
#include "../core/Types.h"
#include "../mctr2/mctr/UserInterface.h"
#include "../mctr2/mctr/MainController.h"
#include "../common/memory.h"
#include "../mctr2/mctr/config_data.h"

//----------------------------------------------------------------------------

namespace jnimw {

//----------------------------------------------------------------------------

/**
 * User interface jnimw implementation.
 */
class Jnimw : public mctr::UserInterface
{
public:
    static Jnimw *userInterface;
    int pipe_fd[2];
    char *pipe_buffer;
    fd_set readfds;

    static bool has_status_message_pending;
    static int pipe_size;

    static pthread_mutex_t mutex;

    /**
     * Configuration data which is filled by calling set_cfg_file()
     * Based on Cli::mycfg
     */
    static config_data mycfg;

public:
    /**
     * Constructor, destructor.
     */
    Jnimw();
    ~Jnimw();

    virtual int enterLoop(int argc, char* argv[]);

    /* Callback interface */
    /**
     * Status of MC has changed.
     */
    virtual void status_change();

    /**
     * Error message from MC.
     */
    virtual void error(int severity, const char* msg);

    /**
     * General notification from MC.
     */
    virtual void notify(const struct timeval* time, const char* source,
                        int severity, const char* msg);

    void create_pipe();
    void destroy_pipe();
    char* read_pipe();
    void write_pipe(const char *buf);

    bool is_pipe_readable();

    static void lock();
    static void unlock();
    static void fatal_error(const char *fmt, ...)
    __attribute__ ((__format__ (__printf__, 1, 2), __noreturn__));
};
//----------------------------------------------------------------------------

}

//----------------------------------------------------------------------------
#endif // JNIMW_JNIMW_H