OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
t_sandesh.h
Go to the documentation of this file.
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 
39 class t_sandesh : public t_struct_common {
40  public:
41  t_sandesh(t_program* program) :
42  t_struct_common(program),
43  type_(NULL) {}
44 
45  t_sandesh(t_program* program, const std::string& name) :
46  t_struct_common(program, name),
47  type_(NULL) {}
48 
49  virtual std::string get_struct_type_name() {
50  return "Sandesh";
51  }
52 
53  virtual bool is_sandesh() const {
54  return true;
55  }
56 
57  void set_type(t_type* type) {
58  type_ = type;
59  }
60 
61  bool exist_opt_field() {
62  members_type::const_iterator m_iter;
63  for (m_iter = members_in_id_order_.begin(); m_iter != members_in_id_order_.end(); ++m_iter) {
64  if ((*m_iter)->get_req() == t_field::T_OPTIONAL) {
65  return true;
66  }
67  }
68  return false;
69  }
70 
71  const t_type* get_type() {
72  return type_;
73  }
74 
76  t_base_type *btype = (t_base_type *) type_;
77  return btype->is_sandesh_system() || btype->is_sandesh_object() ||
78  btype->is_sandesh_flow() || btype->is_sandesh_uve();
79  }
80 
81  virtual bool has_key_annotation() const;
82 
83  private:
85 };
86 
87 #endif
Definition: t_type.h:48
bool is_level_category_supported() const
Definition: t_sandesh.h:75
t_sandesh(t_program *program)
Definition: t_sandesh.h:41
void set_type(t_type *type)
Definition: t_sandesh.h:57
uint8_t type
Definition: load_balance.h:109
virtual std::string get_struct_type_name()
Definition: t_sandesh.h:49
virtual bool is_sandesh() const
Definition: t_sandesh.h:53
virtual bool has_key_annotation() const
members_type members_in_id_order_
t_sandesh(t_program *program, const std::string &name)
Definition: t_sandesh.h:45
const t_type * get_type()
Definition: t_sandesh.h:71
bool exist_opt_field()
Definition: t_sandesh.h:61
t_type * type_
Definition: t_sandesh.h:84