Merge pull request #70 from balaskoa/master
[deliverable/titan.core.git] / JNI / jnimw.h
CommitLineData
d44e3c4f 1/******************************************************************************
2 * Copyright (c) 2000-2016 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 * Contributors:
9 * Balasko, Jeno
10 * Lovassy, Arpad
11 *
12 ******************************************************************************/
970ed795
EL
13#ifndef JNIMW_JNIMW_H
14#define JNIMW_JNIMW_H
15//----------------------------------------------------------------------------
16
17#include <stdio.h>
18#include <pthread.h>
19#include <jni.h>
20#include "../core/Types.h"
21#include "../mctr2/mctr/UserInterface.h"
22#include "../mctr2/mctr/MainController.h"
23#include "../common/memory.h"
24#include "../mctr2/mctr/config_data.h"
25
26//----------------------------------------------------------------------------
27
28namespace jnimw {
29
30//----------------------------------------------------------------------------
31
32/**
33 * User interface jnimw implementation.
34 */
35class Jnimw : public mctr::UserInterface
36{
37public:
38 static Jnimw *userInterface;
39 int pipe_fd[2];
40 char *pipe_buffer;
41 fd_set readfds;
42
43 static bool has_status_message_pending;
44 static int pipe_size;
45
46 static pthread_mutex_t mutex;
47
48 /**
49 * Configuration data which is filled by calling set_cfg_file()
50 * Based on Cli::mycfg
51 */
52 static config_data mycfg;
53
54public:
55 /**
56 * Constructor, destructor.
57 */
58 Jnimw();
59 ~Jnimw();
60
61 virtual int enterLoop(int argc, char* argv[]);
62
63 /* Callback interface */
64 /**
65 * Status of MC has changed.
66 */
67 virtual void status_change();
68
69 /**
70 * Error message from MC.
71 */
72 virtual void error(int severity, const char* msg);
73
74 /**
75 * General notification from MC.
76 */
77 virtual void notify(const struct timeval* time, const char* source,
78 int severity, const char* msg);
79
80 void create_pipe();
81 void destroy_pipe();
82 char* read_pipe();
83 void write_pipe(const char *buf);
84
85 bool is_pipe_readable();
86
87 static void lock();
88 static void unlock();
89 static void fatal_error(const char *fmt, ...)
90 __attribute__ ((__format__ (__printf__, 1, 2), __noreturn__));
91};
92//----------------------------------------------------------------------------
93
94}
95
96//----------------------------------------------------------------------------
97#endif // JNIMW_JNIMW_H
This page took 0.039257 seconds and 5 git commands to generate.