]> Creatis software - bbtk.git/blobdiff - packages/wx/src/bbwxFreeMemoryAlert.cxx
FreeMemoryAlert
[bbtk.git] / packages / wx / src / bbwxFreeMemoryAlert.cxx
diff --git a/packages/wx/src/bbwxFreeMemoryAlert.cxx b/packages/wx/src/bbwxFreeMemoryAlert.cxx
new file mode 100644 (file)
index 0000000..ab4116b
--- /dev/null
@@ -0,0 +1,83 @@
+//===== 
+// 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)
+//===== 
+#include "bbwxFreeMemoryAlert.h"
+#include "bbwxPackage.h"
+#include <wx/msgdlg.h>
+
+namespace bbwx
+{
+
+BBTK_ADD_BLACK_BOX_TO_PACKAGE(wx,FreeMemoryAlert)
+BBTK_BLACK_BOX_IMPLEMENTATION(FreeMemoryAlert,bbtk::AtomicBlackBox);
+//===== 
+// 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)
+//===== 
+void FreeMemoryAlert::Process()
+{
+
+// THE MAIN PROCESSING METHOD BODY
+//   Here we simply set the input 'In' value to the output 'Out'
+//   And print out the output value
+// INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
+//    void bbSet{Input|Output}NAME(const TYPE&)
+//    const TYPE& bbGet{Input|Output}NAME() const 
+//    Where :
+//    * NAME is the name of the input/output
+//      (the one provided in the attribute 'name' of the tag 'input')
+//    * TYPE is the C++ type of the input/output
+//      (the one provided in the attribute 'type' of the tag 'input')
+
+       double memfreeGB = (double) (wxGetFreeMemory().ToLong()/1000000000.0);
+       if ( memfreeGB < bbGetInputFreeMemoryLimit() ) 
+       {
+               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(),
+                                                               memfreeGB ),
+                                                               _T("Warning!"), 
+                                                               wxOK | wxICON_INFORMATION, 
+                                                               NULL);          
+       } // if memfree
+
+
+  
+}
+//===== 
+// 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)
+//===== 
+void FreeMemoryAlert::bbUserSetDefaultValues()
+{
+
+//  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
+//    Here we initialize the input 'In' to 0
+   bbSetInputFreeMemoryLimit(1);
+  
+}
+//===== 
+// 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)
+//===== 
+void FreeMemoryAlert::bbUserInitializeProcessing()
+{
+
+//  THE INITIALIZATION METHOD BODY :
+//    Here does nothing 
+//    but this is where you should allocate the internal/output pointers 
+//    if any 
+
+  
+}
+//===== 
+// 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)
+//===== 
+void FreeMemoryAlert::bbUserFinalizeProcessing()
+{
+
+//  THE FINALIZATION METHOD BODY :
+//    Here does nothing 
+//    but this is where you should desallocate the internal/output pointers 
+//    if any
+  
+}
+}
+// EO namespace bbwx
+
+