source: golgotha/src/i4/test/dll_test/test2.cc @ 80

Last change on this file since 80 was 80, checked in by Sam Hocevar, 14 years ago
  • Adding the Golgotha source code. Not sure what's going to be interesting in there, but since it's all public domain, there's certainly stuff to pick up.
File size: 1.4 KB
Line 
1/********************************************************************** <BR>
2  This file is part of Crack dot Com's free source code release of
3  Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
4  information about compiling & licensing issues visit this URL</a>
5  <PRE> If that doesn't help, contact Jonathan Clark at
6  golgotha_source@usa.net (Subject should have "GOLG" in it)
7***********************************************************************/
8
9#include "test.hh"
10
11CStart startup("Test2");
12
13class CTest2 : public CBase
14{
15protected:
16  virtual char *Type() { return "Test2"; }
17public:
18  int accesses;
19  CBase *sub;
20
21  CTest2(char *name) : CBase(name), accesses(0), sub(0) {}
22
23  ~CTest2()
24  {
25    if (sub)
26      delete sub;
27    sub = 0;
28  }
29
30  virtual void Action(char *command)
31  {
32    accesses++;
33    switch (command[0]) {
34    case 'c':
35      if (sub)
36        delete sub;
37      sub = Make("Test1","subobject");
38      break;
39    case 's':
40      sub->Action(command+2);
41      break;
42    case 'p':
43      print();
44      break;
45    case 'a':
46      printf("I've been accessed %d times.\n", accesses);
47      break;
48    }
49  }
50};
51
52class CTest2Foundry : public CFoundry
53{
54public:
55  char *Type() { return "Test2"; }
56  CBase *Make(char *name) { return new CTest2(name); }
57} CTest2Foundry;
58
59extern "C" void test2(int a, int b)
60{
61  printf("Test 2 succesfully executed with %d and %d\n",a,b);
62}
Note: See TracBrowser for help on using the repository browser.