LCOV - code coverage report
Current view: top level - root/contrail/src/contrail-common/sandesh/compiler/parse - t_function.h (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 0 37 0.0 %
Date: 2026-08-03 02:19:58 Functions: 0 10 0.0 %
Legend: Lines: hit not hit

          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             : 
      20             : #ifndef T_FUNCTION_H
      21             : #define T_FUNCTION_H
      22             : 
      23             : #include <string>
      24             : #include "t_type.h"
      25             : #include "t_struct.h"
      26             : #include "t_doc.h"
      27             : 
      28             : /**
      29             :  * Representation of a function. Key parts are return type, function name,
      30             :  * optional modifiers, and an argument list, which is implemented as a thrift
      31             :  * struct.
      32             :  *
      33             :  */
      34             : class t_function : public t_doc {
      35             :  public:
      36           0 :   t_function(t_type* returntype,
      37             :              std::string name,
      38             :              t_struct* arglist,
      39             :              bool oneway=false
      40             : #ifdef SANDESH
      41             :              ,
      42             :              bool is_virtual=false,
      43             :              bool is_static=false
      44             : #endif
      45           0 :              ) :
      46           0 :     returntype_(returntype),
      47           0 :     name_(name),
      48           0 :     arglist_(arglist),
      49           0 :     oneway_(oneway),
      50             : #ifdef SANDESH
      51           0 :     virtual_(is_virtual),
      52           0 :     static_(is_static)
      53             : #endif
      54             :   {
      55           0 :     xceptions_ = new t_struct(NULL);
      56           0 :   }
      57             : 
      58           0 :   t_function(t_type* returntype,
      59             :              std::string name,
      60             :              t_struct* arglist,
      61             :              t_struct* xceptions,
      62             :              bool oneway=false
      63             : #ifdef SANDESH
      64             :              ,
      65             :              bool is_virtual=false,
      66             :              bool is_static=false
      67             : #endif
      68           0 :              ) :
      69           0 :     returntype_(returntype),
      70           0 :     name_(name),
      71           0 :     arglist_(arglist),
      72           0 :     xceptions_(xceptions),
      73           0 :     oneway_(oneway)
      74             : #ifdef SANDESH
      75             :     ,
      76           0 :     virtual_(is_virtual),
      77           0 :     static_(is_static)
      78             : #endif
      79             :   {
      80           0 :     if (oneway_ && !xceptions_->get_members().empty()) {
      81           0 :       throw std::string("Oneway methods can't throw exceptions.");
      82             :     }
      83           0 :   }
      84             : 
      85           0 :   ~t_function() {}
      86             : 
      87           0 :   t_type* get_returntype() const {
      88           0 :     return returntype_;
      89             :   }
      90             : 
      91           0 :   const std::string& get_name() const {
      92           0 :     return name_;
      93             :   }
      94             : 
      95           0 :   t_struct* get_arglist() const {
      96           0 :     return arglist_;
      97             :   }
      98             : 
      99           0 :   t_struct* get_xceptions() const {
     100           0 :     return xceptions_;
     101             :   }
     102             : 
     103           0 :   bool is_oneway() const {
     104           0 :     return oneway_;
     105             :   }
     106             : #ifdef SANDESH
     107           0 :   bool is_virtual() const {
     108           0 :     return virtual_;
     109             :   }
     110             : 
     111           0 :   bool is_static() const {
     112           0 :     return static_;
     113             :   }
     114             : #endif
     115             : 
     116             :  private:
     117             :   t_type* returntype_;
     118             :   std::string name_;
     119             :   t_struct* arglist_;
     120             :   t_struct* xceptions_;
     121             :   bool oneway_;
     122             : #ifdef SANDESH
     123             :   bool virtual_;
     124             :   bool static_;
     125             : #endif
     126             : };
     127             : 
     128             : #endif

Generated by: LCOV version 1.14