]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/ctables.h
26140c607578f5617e00b0c75ca79463607a0f0f
[user/henk/code/inspircd.git] / include / ctables.h
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
6  *                       E-mail:
7  *                <brain@chatspike.net>
8  *                <Craig@chatspike.net>
9  *     
10  * Written by Craig Edwards, Craig McLure, and others.
11  * This program is free but copyrighted software; see
12  *            the file COPYING for details.
13  *
14  * ---------------------------------------------------
15  */
16  
17 #ifndef __CTABLES_H__
18 #define __CTABLES_H__
19
20
21 #include "inspircd_config.h"
22 #include "hash_map.h"
23 #include "base.h"
24
25 class userrec;
26
27 /*typedef void (handlerfunc) (char**, int, userrec*);*/
28
29 /** A structure that defines a command
30  */
31 class command_t : public Extensible
32 {
33  public:
34         /** Command name
35         */
36          std::string command;
37         /** User flags needed to execute the command or 0
38          */
39         char flags_needed;
40         /** Minimum number of parameters command takes
41         */
42         int min_params;
43         /** used by /stats m
44          */
45         long use_count;
46         /** used by /stats m
47          */
48         long total_bytes;
49         /** used for resource tracking between modules
50          */
51         std::string source;
52         /** True if the command is disabled to non-opers
53          */
54         bool disabled;
55
56         command_t(const std::string &cmd, char flags, int minpara) : command(cmd), flags_needed(flags), min_params(minpara), disabled(false)
57         {
58                 use_count = total_bytes = 0;
59                 source = "<core>";
60         }
61
62         virtual void Handle(const char** parameters, int pcnt, userrec* user) = 0;
63
64         void Disable(bool setting)
65         {
66                 disabled = setting;
67         }
68
69         bool IsDisabled()
70         {
71                 return disabled;
72         }
73
74         virtual ~command_t() {}
75 };
76
77 typedef nspace::hash_map<std::string,command_t*> command_table;
78
79 #endif