]> git.ipfire.org Git - thirdparty/squid.git/blame - src/mgr/Action.h
Boilerplate: update copyright blurbs on src/
[thirdparty/squid.git] / src / mgr / Action.h
CommitLineData
8822ebee 1/*
bbc27441 2 * Copyright (C) 1996-2014 The Squid Software Foundation and contributors
8822ebee 3 *
bbc27441
AJ
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
8822ebee
AR
7 */
8
bbc27441
AJ
9/* DEBUG: section 16 Cache Manager API */
10
8822ebee
AR
11#ifndef SQUID_MGR_ACTION_H
12#define SQUID_MGR_ACTION_H
13
14#include "ipc/forward.h"
15#include "mgr/forward.h"
16
17class StoreEntry;
18
19namespace Mgr
20{
21
22/// Base API for organizing the processing of a compiled cache manager command.
23/// Not a job because all methods are synchronous (but they may start jobs).
24class Action: public RefCountable
25{
26public:
27 typedef RefCount<Action> Pointer;
28
29public:
30 Action(const CommandPointer &aCmd);
31 virtual ~Action();
32
8822ebee
AR
33 /* for local Cache Manager use */
34
35 /// collect + fillEntry: collect local information and fill the store entry
36 void run(StoreEntry *entry, bool writeHttpHeader);
37
38 /// prepare store entry, dump info, close store entry (if possible)
39 void fillEntry(StoreEntry *entry, bool writeHttpHeader);
40
8822ebee
AR
41 /* for global Coordinator use */
42
43 /// incrementally merge in remote information (of the same action type)
44 virtual void add(const Action &action);
45
8822ebee
AR
46 /* global-local communication */
47
48 /// respond to Coordinator request; default is to collect and sendResponse
49 virtual void respond(const Request &request);
50
51 /// pack collected action info into a message to be sent to Coordinator
52 virtual void pack(Ipc::TypedMsgHdr &msg) const {}
53 /// unpack action info from the message received by Coordinator
54 virtual void unpack(const Ipc::TypedMsgHdr &msg) {}
55
56 /// notify Coordinator that this action is done with local processing
57 void sendResponse(unsigned int requestId);
58
8822ebee
AR
59 /* Action properties */
60
61 /// whether at least some local kid info can be combined and, hence, the
62 /// combined data should be written at the end of the coordinated response
63 virtual bool aggregatable() const { return true; } // most kid classes are
64
65 bool atomic() const; ///< dump() call writes everything before returning
66 const char *name() const; ///< label as seen in the cache manager menu
67 const Command &command() const; ///< the cause of this action
68
69 StoreEntry *createStoreEntry() const; ///< creates store entry from params
70
8088f8d0
AJ
71 ///< Content-Type: header value for this report
72 virtual const char *contentType() const {return "text/plain;charset=utf-8";}
73
8822ebee
AR
74protected:
75 /// calculate and keep local action-specific information
76 virtual void collect() {}
77
d9fc6862 78 /** start writing action-specific info to Store entry;
8822ebee
AR
79 * may collect info during dump, especially if collect() did nothing
80 * non-atomic() actions may continue writing asynchronously after returning
81 */
82 virtual void dump(StoreEntry *entry) {}
83
8822ebee
AR
84private:
85 const CommandPointer cmd; ///< the command that caused this action
86
8822ebee
AR
87private:
88 Action(const Action &); // not implemented
89 Action &operator= (const Action &); // not implemented
90};
91
92} // namespace Mgr
93
94#endif /* SQUID_MGR_ACTION_H */