Update the changelog
[opencv] / apps / Hawk / Hawk.h
1 /*M///////////////////////////////////////////////////////////////////////////////////////
2 //
3 //  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
4 //
5 //  By downloading, copying, installing or using the software you agree to this license.
6 //  If you do not agree to this license, do not download, install,
7 //  copy or use the software.
8 //
9 //
10 //                        Intel License Agreement
11 //                For Open Source Computer Vision Library
12 //
13 // Copyright (C) 2000, Intel Corporation, all rights reserved.
14 // Third party copyrights are property of their respective owners.
15 //
16 // Redistribution and use in source and binary forms, with or without modification,
17 // are permitted provided that the following conditions are met:
18 //
19 //   * Redistribution's of source code must retain the above copyright notice,
20 //     this list of conditions and the following disclaimer.
21 //
22 //   * Redistribution's in binary form must reproduce the above copyright notice,
23 //     this list of conditions and the following disclaimer in the documentation
24 //     and/or other materials provided with the distribution.
25 //
26 //   * The name of Intel Corporation may not be used to endorse or promote products
27 //     derived from this software without specific prior written permission.
28 //
29 // This software is provided by the copyright holders and contributors "as is" and
30 // any express or implied warranties, including, but not limited to, the implied
31 // warranties of merchantability and fitness for a particular purpose are disclaimed.
32 // In no event shall the Intel Corporation or contributors be liable for any direct,
33 // indirect, incidental, special, exemplary, or consequential damages
34 // (including, but not limited to, procurement of substitute goods or services;
35 // loss of use, data, or profits; or business interruption) however caused
36 // and on any theory of liability, whether in contract, strict liability,
37 // or tort (including negligence or otherwise) arising in any way out of
38 // the use of this software, even if advised of the possibility of such damage.
39 //
40 //M*/// Hawk.h : main header file for the HAWK application
41 //
42
43 #if !defined(AFX_HAWK_H__6FFD53A7_939A_11D3_AE7E_00A0C9989BC6__INCLUDED_)
44 #define AFX_HAWK_H__6FFD53A7_939A_11D3_AE7E_00A0C9989BC6__INCLUDED_
45
46 #if _MSC_VER > 1000
47 #pragma once
48 #endif // _MSC_VER > 1000
49
50 #ifndef __AFXWIN_H__
51         #error include 'stdafx.h' before including this file for PCH
52 #endif
53
54 #include "resource.h"       // main symbols
55
56 #include "HeadBand.h"
57 #include "FuncDialog.h"
58 #include "eicdllwrap.h"
59
60 #ifdef __cplusplus
61 extern "C" {
62 #endif // __cplusplus
63 #include "hawkwrap.h"
64 #include <eic.h>
65 #ifdef malloc
66 #undef malloc
67 #endif
68 #ifdef realloc
69 #undef realloc
70 #endif
71 #ifdef free
72 #undef free
73 #endif
74 #ifdef __cplusplus
75 }
76 #endif // __cplusplus
77
78 #pragma warning(disable:4786)
79 #include <vector>
80 #include <string>
81 //#include <xstring>
82 using namespace std;
83
84
85 typedef struct
86 {
87     FILE* read;
88     FILE* write;
89 } stream_pipe;
90
91 /////////////////////////////////////////////////////////////////////////////
92 // CHawkApp:
93 // See Hawk.cpp for the implementation of this class
94 //
95
96 typedef struct
97 {
98     CString m_path;
99     HMODULE m_handle;
100     CStringArray* m_functions;
101     plugin_info m_info;
102     void (*m_GetInfo)(plugin_info*);
103     void (*m_SetErrLevel)(errlevel_t);
104     void (*m_SetErrMark)(jmp_buf*);
105     void (*m_SetEiCStack)(AR_t**);
106     void (*m_SetEiCCallback)(void(*)(void*));
107     void (*m_GetFunctions)(char***, val_t (***)(void), int*);
108 } plugin_t;
109
110 template<> void AFXAPI DestructElements<CMenu*> (CMenu** pElements, int nCount);
111 typedef CArray<CMenu*, CMenu*> CMenuArray;
112
113 template<> void AFXAPI DestructElements<plugin_t> (plugin_t* pElements, int nCount);
114 typedef CArray<plugin_t, plugin_t&> CPluginArray;
115
116 struct type_expr;
117
118 typedef void(__cdecl *HAWK_SIGFUNC)(int);
119
120 //typedef basic_string<char> string;
121
122 class CHawkApp : public CWinApp
123 {
124 private:
125     CArray<void*, void*> m_funcDialogs;
126     CMenu m_mainMenu;
127     CMenuArray m_childMenus;
128     CHeadBand m_headband;
129     
130 public:
131         CFuncDialog* GetFuncDialog(int index);
132         CString GenDecl(const char* name);
133         BOOL LoadModuleFunction(HMODULE handle, LPCTSTR name, BOOL isOpenCV);
134         BOOL EnumModuleFunctions(LPCTSTR filename, CStringArray& names);
135         BOOL EnumHeaders(LPCTSTR path);
136         BOOL Attach(string filename);
137         int m_pipeDataSize;
138 #ifndef NDEBUG
139     CStringArray m_wrapperStrings;
140 #endif
141         void LoadModuleFunctions(LPCTSTR filename, LPCTSTR modulename);
142         CString GetTypeString(void* _type, const char* name = "");
143         CString m_EiCOut;
144         HANDLE m_printfMutex;
145     HANDLE m_dsMutex;
146         void CloseEiCHandles();
147         BOOL InitEiCHandles();
148         const CStringArray& GetVideoPath();
149         void AddVideoPath(const CString& path);
150         void SetStatusString(LPCTSTR str);
151         void SetSBRun(BOOL sbRun);
152         BOOL GetSBRun();
153         void UpdateMark(jmp_buf* mark = 0);
154     CPluginArray m_plugins;
155         jmp_buf m_mark;
156         errlevel_t GetErrLevel();
157         void SetErrLevel(errlevel_t level);
158         void ExitEiC();
159         CStringArray* GetFunctions(int i);
160         CMenu* GetContextMenu();
161         void InitPopupMenu();
162         LPCTSTR GetModulePath();
163         BOOL FindAndAttach(LPCTSTR path, LPCTSTR fileName);
164         stream_pipe m_eicOut;
165     stream_pipe m_eicErr;
166
167     CMap<int, int, HAWK_SIGFUNC, HAWK_SIGFUNC> m_eicSigFuncs;
168
169     BOOL InitEiC();
170         CHawkApp();
171     ~CHawkApp();
172
173 // Overrides
174         // ClassWizard generated virtual function overrides
175         //{{AFX_VIRTUAL(CHawkApp)
176         public:
177         virtual BOOL InitInstance();
178         virtual int ExitInstance();
179         //}}AFX_VIRTUAL
180
181 // Implementation
182         //{{AFX_MSG(CHawkApp)
183         afx_msg void OnAppAbout();
184                 // NOTE - the ClassWizard will add and remove member functions here.
185                 //    DO NOT EDIT what you see in these blocks of generated code !
186         //}}AFX_MSG
187         DECLARE_MESSAGE_MAP()
188 private:
189         void InitPopupDialogs();
190         BOOL LoadModules();
191     vector<string> m_includeDirs;
192     vector<string> m_includeFiles;
193         vector<string> m_includeFilePath;
194         BOOL AddStructType(const type_expr* type);
195         CPtrArray m_structTypes;
196         BOOL GenAutoWrapper(void* func, LPCTSTR func_name);
197         CString m_EiCErrFile;
198         CStringArray m_videoPath;
199         BOOL m_sbRun;
200         errlevel_t m_errlevel;
201         CStringArray m_eicFiles;
202         BOOL LoadPluginFunctions(HMODULE module);
203         void LoadPlugins();
204         CString m_wrappersPath;
205         CString m_modulePath;
206         BOOL InitModulePath();
207 };
208
209
210 /////////////////////////////////////////////////////////////////////////////
211
212 //{{AFX_INSERT_LOCATION}}
213 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
214
215 #endif // !defined(AFX_HAWK_H__6FFD53A7_939A_11D3_AE7E_00A0C9989BC6__INCLUDED_)