32 using namespace basis;
41 #define BASE_LOG(to_print) EMERGENCY_LOG(program_wide_logger().get(), astring(to_print))
42 #define LOG(to_print) CLASS_EMERGENCY_LOG(program_wide_logger().get(), astring(to_print))
50 application_example();
51 ~application_example();
55 virtual void handle_timer();
58 virtual void handle_startup();
61 virtual void handle_shutdown();
64 virtual int execute();
76 application_example::application_example()
81 application_example::~application_example()
88 \nUsage: memory_hog {memorySize}\n\
90 This application will consume a requested amount of memory until either\n\
91 (1) the applications is interrupted or terminated, or (2) the application\n\
92 is no longer given memory when it requests it (whether due to account limits\n\
93 or to a lack of remaining allocatable memory), or (3) the requested amount\n\
94 has been allocated.\n\
95 The application will then sit back idly and occasionally riffle through its\n\
96 big bag of memory in an attempt to keep most of it in physical memory rather\n\
97 than virtual memory.\n\
98 This is not a hostile act unless used unwisely; this program is intended\n\
99 to get an unloaded machine into a predictable memory state.\n\
100 **DO NOT use this program without system administrator permission.**"
105 void application_example::handle_startup()
108 LOG(
"starting up now.");
111 void application_example::handle_shutdown()
114 LOG(
"shutting down now.");
117 void application_example::handle_timer()
123 int application_example::execute()
128 LOG(
a_sprintf(
"cmd line has %d entries", cmds.entries()));
130 if (cmds.entries() < 1) {
131 BASE_LOG(
"You need to provide a number on the command line....");
137 LOG(
a_sprintf(
"hoo hah! got a text thingy of: %s", size_as_text.
s()));
139 if (size_as_text.
find(
'.') < 0) {
142 size_as_text +=
".0";
145 double how_fat = size_as_text.
convert(
double(0.0));
147 LOG(
a_sprintf(
"got a number from user of: %f", how_fat));
int print_instructions(bool good, const astring &program_name)
The application_shell is a base object for console programs.
a_sprintf is a specialization of astring that provides printf style support.
Provides a dynamically resizable ASCII character string.
const char * s() const
synonym for observe. the 's' stands for "string", if that helps.
virtual char get(int index) const
a constant peek at the string's internals at the specified index.
int convert(int default_value) const
Converts the string into a corresponding integer.
int find(char to_find, int position=0, bool reverse=false) const
Locates "to_find" in "this".
#define DEFINE_CLASS_NAME(objname)
Defines the name of a class by providing a couple standard methods.
#define FUNCDEF(func_in)
FUNCDEF sets the name of a function (and plugs it into the callstack).
Provides macros that implement the 'main' program of an application.
#define HOOPLE_MAIN(obj_name, obj_args)
options that should work for most unix and linux apps.
#define BASE_LOG(to_print)
const int MEMORY_CHECKING_INTERVAL
Implements an application lock to ensure only one is running at once.
The guards collection helps in testing preconditions and reporting errors.
const int SECOND_ms
Number of milliseconds in a second.
A logger that sends to the console screen using the standard output device.
A dynamic container class that holds any kind of object via pointers.
Useful support functions for unit testing, especially within hoople.
#define static_class_name()