blob: f5665b68d89a37f1d6087e7abe46ffb86dcee94f [file] [log] [blame]
Mark Sleee9ce01c2007-05-16 02:29:53 +00001// Copyright (c) 2006- Facebook
2// Distributed under the Thrift Software License
3//
4// See accompanying file LICENSE or visit the Thrift site at:
5// http://developers.facebook.com/thrift/
6
Mark Slee31985722006-05-24 21:45:31 +00007#ifndef T_SERVICE_H
8#define T_SERVICE_H
9
10#include "t_function.h"
11#include <vector>
12
Mark Sleef0712dc2006-10-25 19:03:57 +000013class t_program;
14
Mark Sleef5377b32006-10-10 01:42:59 +000015/**
16 * A service consists of a set of functions.
17 *
18 * @author Mark Slee <mcslee@facebook.com>
19 */
Mark Sleef0712dc2006-10-25 19:03:57 +000020class t_service : public t_type {
Mark Slee31985722006-05-24 21:45:31 +000021 public:
Mark Sleef0712dc2006-10-25 19:03:57 +000022 t_service(t_program* program) :
23 t_type(program),
24 extends_(NULL) {}
Mark Slee31985722006-05-24 21:45:31 +000025
Mark Sleef0712dc2006-10-25 19:03:57 +000026 bool is_service() const {
27 return true;
28 }
29
30 void set_extends(t_service* extends) {
31 extends_ = extends;
Mark Sleef5377b32006-10-10 01:42:59 +000032 }
Mark Slee31985722006-05-24 21:45:31 +000033
Mark Sleef5377b32006-10-10 01:42:59 +000034 void add_function(t_function* func) {
35 functions_.push_back(func);
36 }
37
Mark Sleef5377b32006-10-10 01:42:59 +000038 const std::vector<t_function*>& get_functions() const {
39 return functions_;
40 }
Mark Slee31985722006-05-24 21:45:31 +000041
Mark Sleef0712dc2006-10-25 19:03:57 +000042 t_service* get_extends() {
43 return extends_;
44 }
45
David Reiss18bf22d2007-08-28 20:49:17 +000046 virtual std::string get_fingerprint_material() const {
47 // Services should never be used in fingerprints.
48 throw "BUG: Can't get fingerprint material for service.";
49 }
50
Mark Slee31985722006-05-24 21:45:31 +000051 private:
Mark Slee31985722006-05-24 21:45:31 +000052 std::vector<t_function*> functions_;
Mark Sleef0712dc2006-10-25 19:03:57 +000053 t_service* extends_;
Mark Slee31985722006-05-24 21:45:31 +000054};
55
56#endif