Line data Source code
1 : /* 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 : * 19 : * Copyright 2006-2017 The Apache Software Foundation. 20 : * https://github.com/apache/thrift 21 : */ 22 : 23 : #ifndef T_SANDESH_H 24 : #define T_SANDESH_H 25 : 26 : #include <string> 27 : 28 : #include "t_type.h" 29 : #include "t_struct_common.h" 30 : #include "t_base_type.h" 31 : 32 : // Forward declare that puppy 33 : class t_program; 34 : 35 : /** 36 : * A sandesh is a container for a set of member fields that has a name. 37 : * 38 : */ 39 : class t_sandesh : public t_struct_common { 40 : public: 41 11608 : t_sandesh(t_program* program) : 42 : t_struct_common(program), 43 11608 : type_(NULL) {} 44 : 45 : t_sandesh(t_program* program, const std::string& name) : 46 : t_struct_common(program, name), 47 : type_(NULL) {} 48 : 49 4666 : virtual std::string get_struct_type_name() { 50 4666 : return "Sandesh"; 51 : } 52 : 53 698 : virtual bool is_sandesh() const { 54 698 : return true; 55 : } 56 : 57 11608 : void set_type(t_type* type) { 58 11608 : type_ = type; 59 11608 : } 60 : 61 5408 : bool exist_opt_field() { 62 5408 : members_type::const_iterator m_iter; 63 28146 : for (m_iter = members_in_id_order_.begin(); m_iter != members_in_id_order_.end(); ++m_iter) { 64 22738 : if ((*m_iter)->get_req() == t_field::T_OPTIONAL) { 65 0 : return true; 66 : } 67 : } 68 5408 : return false; 69 : } 70 : 71 81760 : const t_type* get_type() { 72 81760 : return type_; 73 : } 74 : 75 7535 : bool is_level_category_supported() const { 76 7535 : t_base_type *btype = (t_base_type *) type_; 77 17365 : return btype->is_sandesh_system() || btype->is_sandesh_object() || 78 17365 : btype->is_sandesh_flow() || btype->is_sandesh_uve(); 79 : } 80 : 81 : virtual bool has_key_annotation() const; 82 : 83 : private: 84 : t_type* type_; 85 : }; 86 : 87 : #endif