From 46d7aa1e632342deddf3844a57c1460da9f20b13 Mon Sep 17 00:00:00 2001 From: Eduardo DAVILA Date: Mon, 10 May 2021 17:54:32 +0200 Subject: [PATCH] FreeMemoryAlert --- packages/wx/src/bbwxFreeMemoryAlert.cxx | 83 +++++++++++++++++++++++++ packages/wx/src/bbwxFreeMemoryAlert.h | 46 ++++++++++++++ packages/wx/src/bbwxLayoutLine.cxx | 8 +-- 3 files changed, 133 insertions(+), 4 deletions(-) create mode 100644 packages/wx/src/bbwxFreeMemoryAlert.cxx create mode 100644 packages/wx/src/bbwxFreeMemoryAlert.h diff --git a/packages/wx/src/bbwxFreeMemoryAlert.cxx b/packages/wx/src/bbwxFreeMemoryAlert.cxx new file mode 100644 index 0000000..ab4116b --- /dev/null +++ b/packages/wx/src/bbwxFreeMemoryAlert.cxx @@ -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 + +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 + + diff --git a/packages/wx/src/bbwxFreeMemoryAlert.h b/packages/wx/src/bbwxFreeMemoryAlert.h new file mode 100644 index 0000000..2628ad4 --- /dev/null +++ b/packages/wx/src/bbwxFreeMemoryAlert.h @@ -0,0 +1,46 @@ +//===== +// 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) +//===== +#ifndef __bbwxFreeMemoryAlert_h_INCLUDED__ +#define __bbwxFreeMemoryAlert_h_INCLUDED__ + +#include "bbwx_EXPORT.h" +#include "bbtkAtomicBlackBox.h" +#include "iostream" + +namespace bbwx +{ + +class bbwx_EXPORT FreeMemoryAlert + : + public bbtk::AtomicBlackBox +{ + BBTK_BLACK_BOX_INTERFACE(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) +//===== + BBTK_DECLARE_INPUT(FreeMemoryLimit,double); +// BBTK_DECLARE_OUTPUT(Out,double); + BBTK_PROCESS(Process); + void Process(); +//===== +// 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) +//===== +}; + +BBTK_BEGIN_DESCRIBE_BLACK_BOX(FreeMemoryAlert,bbtk::AtomicBlackBox); + BBTK_NAME("FreeMemoryAlert"); + BBTK_AUTHOR("InfoDev"); + BBTK_DESCRIPTION("No Description."); + BBTK_CATEGORY("empty"); + BBTK_INPUT(FreeMemoryAlert,FreeMemoryLimit,"(default 1) Limit free memory en GB",double,""); +// BBTK_OUTPUT(FreeMemoryAlert,Out,"First output",double,""); +BBTK_END_DESCRIBE_BLACK_BOX(FreeMemoryAlert); +//===== +// 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) +//===== +} +// EO namespace bbwx + +#endif // __bbwxFreeMemoryAlert_h_INCLUDED__ + diff --git a/packages/wx/src/bbwxLayoutLine.cxx b/packages/wx/src/bbwxLayoutLine.cxx index b166737..cdd1322 100644 --- a/packages/wx/src/bbwxLayoutLine.cxx +++ b/packages/wx/src/bbwxLayoutLine.cxx @@ -78,10 +78,10 @@ namespace bbwx } - void LayoutLine::Process() - { - PutWinTitle(); - } +void LayoutLine::Process() +{ + PutWinTitle(); +} /* -- 2.45.1