blob: eee2dac1ec34048998f424ae0cf774cc0c595f6a [file] [log] [blame]
David Reissea2cba82009-03-30 21:35:00 +00001/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
Mark Sleee9ce01c2007-05-16 02:29:53 +000019
Mark Slee31985722006-05-24 21:45:31 +000020#ifndef T_SERVICE_H
21#define T_SERVICE_H
22
23#include "t_function.h"
24#include <vector>
25
Mark Sleef0712dc2006-10-25 19:03:57 +000026class t_program;
27
Mark Sleef5377b32006-10-10 01:42:59 +000028/**
29 * A service consists of a set of functions.
30 *
Mark Sleef5377b32006-10-10 01:42:59 +000031 */
Mark Sleef0712dc2006-10-25 19:03:57 +000032class t_service : public t_type {
Mark Slee31985722006-05-24 21:45:31 +000033 public:
Mark Sleef0712dc2006-10-25 19:03:57 +000034 t_service(t_program* program) :
35 t_type(program),
36 extends_(NULL) {}
Mark Slee31985722006-05-24 21:45:31 +000037
Mark Sleef0712dc2006-10-25 19:03:57 +000038 bool is_service() const {
39 return true;
40 }
41
42 void set_extends(t_service* extends) {
43 extends_ = extends;
Mark Sleef5377b32006-10-10 01:42:59 +000044 }
Mark Slee31985722006-05-24 21:45:31 +000045
Mark Sleef5377b32006-10-10 01:42:59 +000046 void add_function(t_function* func) {
47 functions_.push_back(func);
48 }
49
Mark Sleef5377b32006-10-10 01:42:59 +000050 const std::vector<t_function*>& get_functions() const {
51 return functions_;
52 }
Mark Slee31985722006-05-24 21:45:31 +000053
Mark Sleef0712dc2006-10-25 19:03:57 +000054 t_service* get_extends() {
55 return extends_;
56 }
57
David Reiss18bf22d2007-08-28 20:49:17 +000058 virtual std::string get_fingerprint_material() const {
59 // Services should never be used in fingerprints.
60 throw "BUG: Can't get fingerprint material for service.";
61 }
62
Mark Slee31985722006-05-24 21:45:31 +000063 private:
Mark Slee31985722006-05-24 21:45:31 +000064 std::vector<t_function*> functions_;
Mark Sleef0712dc2006-10-25 19:03:57 +000065 t_service* extends_;
Mark Slee31985722006-05-24 21:45:31 +000066};
67
68#endif