PLplot  5.11.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
wxwidgets_comms.h
Go to the documentation of this file.
1 // Copyright (C) 2008 Werner Smekal
2 //
3 // This file is part of PLplot.
4 //
5 // PLplot is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU Library General Public License as published
7 // by the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
9 //
10 // PLplot is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU Library General Public License for more details.
14 //
15 // You should have received a copy of the GNU Library General Public License
16 // along with PLplot; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 //
19 
20 #ifndef __PL_WXWIDGETS_COMMS__
21 #define __PL_WXWIDGETS_COMMS__
22 
23 #include "plplotP.h"
24 #ifdef WIN32
25 #include <Windows.h>
26 #else
27 #include <sys/mman.h>
28 #include <sys/stat.h>
29 #include <fcntl.h>
30 #include <semaphore.h>
31 #include <errno.h>
32 #endif
33 
34 //data transmission codes
35 const unsigned char transmissionRegular = 0;
36 const unsigned char transmissionSkipFileEnd = 1;
37 const unsigned char transmissionEndOfPage = 2;
38 const unsigned char transmissionBeginPage = 3;
39 const unsigned char transmissionLocate = 4;
40 const unsigned char transmissionPartial = 5;
41 const unsigned char transmissionComplete = 6;
42 
43 
45 {
46  size_t readLocation;
47  size_t writeLocation;
50  size_t completeFlag;
52 };
53 
55 
57 {
58 public:
59  PLMemoryMap();
60  PLMemoryMap( const char *name, PLINT size, bool mustExist, bool mustNotExist );
61  void create( const char *name, PLINT size, bool mustExist, bool mustNotExist );
62  void close();
63  ~PLMemoryMap();
64  char *getBuffer() { return (char *) m_buffer; }
65  bool isValid() { return m_buffer != NULL; }
66  size_t getSize() { return m_size; }
67 private:
68 #ifdef WIN32
69  HANDLE m_mapFile;
70 #else
71  int m_mapFile;
72  char * m_name;
73 #endif
74  size_t m_size;
75  void *m_buffer;
76 };
77 
79 {
80 public:
81  PLNamedMutex();
82  PLNamedMutex( const char *name, bool aquireOnCreate = false );
83  ~PLNamedMutex();
84  void create( const char *name, bool aquireOnCreate = false );
85  void clear();
86  void aquire();
87  bool aquire( unsigned long millisecs );
88  bool aquireNoWait();
89  void release();
90  bool isValid();
91 private:
92  bool m_haveLock;
93 #ifdef WIN32
94  HANDLE m_mutex;
95 #else
96  sem_t * m_mutex;
97 #endif
98 };
99 
101 {
102 public:
105 private:
107  //remove default constructors
111 };
112 
113 #endif