feisty meow concerns codebase 2.140
base_application.h
Go to the documentation of this file.
1#ifndef BASE_APPLICATION_CLASS
2#define BASE_APPLICATION_CLASS
3
5// Name : base_application
6// Author : Chris Koeritz
8// Copyright (c) 2000-$now By Author. This program is free software; you can
9// redistribute it and/or modify it under the terms of the GNU General Public
10// License as published by the Free Software Foundation:
11// http://www.gnu.org/licenses/gpl.html
12// or under the terms of the GNU Library license:
13// http://www.gnu.org/licenses/lgpl.html
14// at your preference. Those licenses describe your legal rights to this
15// software, and no other rights or warranties apply.
16// Please send updates for this code to: fred@gruntose.com -- Thanks, fred.
18
19#include <basis/contracts.h>
21
22namespace application {
23
25
31class base_application : public virtual basis::nameable
32{
33public:
34 virtual const char *class_name() const = 0; // must be provided by implementor.
35
36 virtual int execute() = 0;
38
40};
41
43
44#if 0
45
47class example_application : public base_application
48{
49public:
50 example_application() : base_application() {}
51 DEFINE_CLASS_NAME("example_application");
52 int execute() { /* do stuff and return final exit value. */ }
53};
54
56int __example__main(int argc, char *argv[])
57{
58 example_application root_program;
59 return root_program.execute();
60}
61
62#endif // example guard.
63
64} //namespace.
65
66#endif // outer guard.
67
Provides a base object for the root application portion of a program.
virtual const char * class_name() const =0
Returns the bare name of this class as a constant character pointer.
virtual int execute()=0
performs the main activity of this particular application object.
Root object for any class that knows its own name.
Definition contracts.h:123
#define DEFINE_CLASS_NAME(objname)
Defines the name of a class by providing a couple standard methods.
Definition enhance_cpp.h:42
Implements an application lock to ensure only one is running at once.