]> Creatis software - bbtk.git/blob - packages/wx/src/bbwxFreeMemoryAlert.cxx
FreeMemoryAlert
[bbtk.git] / packages / wx / src / bbwxFreeMemoryAlert.cxx
1 //===== 
2 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
3 //===== 
4 #include "bbwxFreeMemoryAlert.h"
5 #include "bbwxPackage.h"
6 #include <wx/msgdlg.h>
7
8 namespace bbwx
9 {
10
11 BBTK_ADD_BLACK_BOX_TO_PACKAGE(wx,FreeMemoryAlert)
12 BBTK_BLACK_BOX_IMPLEMENTATION(FreeMemoryAlert,bbtk::AtomicBlackBox);
13 //===== 
14 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
15 //===== 
16 void FreeMemoryAlert::Process()
17 {
18
19 // THE MAIN PROCESSING METHOD BODY
20 //   Here we simply set the input 'In' value to the output 'Out'
21 //   And print out the output value
22 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
23 //    void bbSet{Input|Output}NAME(const TYPE&)
24 //    const TYPE& bbGet{Input|Output}NAME() const 
25 //    Where :
26 //    * NAME is the name of the input/output
27 //      (the one provided in the attribute 'name' of the tag 'input')
28 //    * TYPE is the C++ type of the input/output
29 //      (the one provided in the attribute 'type' of the tag 'input')
30
31         double memfreeGB = (double) (wxGetFreeMemory().ToLong()/1000000000.0);
32         if ( memfreeGB < bbGetInputFreeMemoryLimit() ) 
33         {
34                 wxMessageBox(wxString::Format(  "This application needs minimum %4.1f Gb to be executed correctly. \nTry to close somes applications you don't need. \n\n Actual free memory = %4.1f Gb\n",bbGetInputFreeMemoryLimit(),
35                                                                 memfreeGB ),
36                                                                 _T("Warning!"), 
37                                                                 wxOK | wxICON_INFORMATION, 
38                                                                 NULL);          
39         } // if memfree
40
41
42   
43 }
44 //===== 
45 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
46 //===== 
47 void FreeMemoryAlert::bbUserSetDefaultValues()
48 {
49
50 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
51 //    Here we initialize the input 'In' to 0
52    bbSetInputFreeMemoryLimit(1);
53   
54 }
55 //===== 
56 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
57 //===== 
58 void FreeMemoryAlert::bbUserInitializeProcessing()
59 {
60
61 //  THE INITIALIZATION METHOD BODY :
62 //    Here does nothing 
63 //    but this is where you should allocate the internal/output pointers 
64 //    if any 
65
66   
67 }
68 //===== 
69 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
70 //===== 
71 void FreeMemoryAlert::bbUserFinalizeProcessing()
72 {
73
74 //  THE FINALIZATION METHOD BODY :
75 //    Here does nothing 
76 //    but this is where you should desallocate the internal/output pointers 
77 //    if any
78   
79 }
80 }
81 // EO namespace bbwx
82
83