# Path: pif_ir/air/objects/table_entry.py
# class TableEntryExact(TableEntryBase):
#     """
#     @brief Match entry for exact matching
#     """
#     def __init__(self, match_values, action_ref, action_params):
#         """
#         @param match_values A map from match fields to values
#         @param action_ref The name of the action to execute
#         @param action_params Map from parameter name to value
#         """
#         TableEntryBase.__init__(self, action_ref, action_params)
#         self.match_values = match_values
# 
#     def check_match(self, parsed_packet):
#         """
#         @brief Check if packet matches this entry
#         @return (action_name, action_param_map) if match; None otherwise
#         """
#         for field_name, value in self.match_values.items():
#             p_value = parsed_packet.get_field(field_name)
#             if p_value is None or p_value != value:
#                 return None
#         return (self.action_ref, self.action_params)
# 
# Path: pif_ir/air/objects/table_entry.py
# class TableEntryTernary(TableEntryBase):
#     """
#     @brief General (ternary) match table
# 
#     Note that an entry here supports exact match as well; if a mask
#     is not specified for a field, then the match is exact.
#     """
#     def __init__(self, match_values, match_masks, action_ref, action_params,
#                  priority):
#         """
#         @param match_values A map from match fields to values
#         @param match_masks A map from match fields to masks for comparing
#         @param action_ref The name of the action to execute
#         @param action_params Map from parameter name to value
#         @param priority The priority of the entry
# 
#         Higher numbers are higher priority
#         """
#         meta_ir_assert(match_masks is None or isinstance(match_masks, dict),
#                    "Bad mask parameter to table_entry initializer")
#         TableEntryBase.__init__(self, action_ref, action_params)
#         self.match_masks = match_masks
#         self.match_values = match_values
#         self.priority = priority
# 
# 
#     def check_match(self, parsed_packet):
#         """
#         @brief Check if packet matches this entry
#         @return (action_name, action_param_map) if match; None otherwise
#         """
#         for field_name, value in self.match_values.items():
#             mask = deref_or_none(self.match_masks, field_name)
#             p_value = parsed_packet.get_field(field_name)
#             if p_value is None:
#                 return None
#             if mask is not None:
#                 if p_value & mask != value & mask:
#                     return None
#             else:
#                 if p_value != value:
#                     return None
# 
#         return (self.action_ref, self.action_params)
# 
# Path: pif_ir/air/objects/table_entry.py
# class TableEntryDefault(TableEntryBase):
#     """
#     Entry object for a default match. Same as TableEntryBase
#     """
#     pass


import sys
from threading import Condition
from pif_ir.meta_ir.common import *
from pif_ir.air.objects.table_entry import TableEntryExact
from pif_ir.air.objects.table_entry import TableEntryTernary
from pif_ir.air.objects.table_entry import TableEntryDefault
            pass
        else:
            raise AirReferenceError("Unknown entry ref type for entry remove")

    def clear(self, clear_stats=True, clear_default=False):
        """
        Remove all entries from the table
        @param clear_stats If True, set table counters to 0
        @param clear_default If True, clear the default entry too
        """
        logging.debug("Clearing table %s" % self.name)
        with self.cond_var:
            if clear_stats:
                self.packet_count = 0
                self.byte_count = 0
            for entry in self.entries:
                # For now, do nothing
                pass
            self.entries = []
            if clear_default:
                self.default_entry = None

    def hit_stats(self):
        """
        @brief Return table counters
        @returns A pair of integers, byte count and packet count
        """
        return (self.byte_count, self.packet_count)

    def set_default_entry(self, entry):

# Path: pif_ir/air/objects/table_entry.py
# class TableEntryExact(TableEntryBase):
#     """
#     @brief Match entry for exact matching
#     """
#     def __init__(self, match_values, action_ref, action_params):
#         """
#         @param match_values A map from match fields to values
#         @param action_ref The name of the action to execute
#         @param action_params Map from parameter name to value
#         """
#         TableEntryBase.__init__(self, action_ref, action_params)
#         self.match_values = match_values
# 
#     def check_match(self, parsed_packet):
#         """
#         @brief Check if packet matches this entry
#         @return (action_name, action_param_map) if match; None otherwise
#         """
#         for field_name, value in self.match_values.items():
#             p_value = parsed_packet.get_field(field_name)
#             if p_value is None or p_value != value:
#                 return None
#         return (self.action_ref, self.action_params)
# 
# Path: pif_ir/air/objects/table_entry.py
# class TableEntryTernary(TableEntryBase):
#     """
#     @brief General (ternary) match table
# 
#     Note that an entry here supports exact match as well; if a mask
#     is not specified for a field, then the match is exact.
#     """
#     def __init__(self, match_values, match_masks, action_ref, action_params,
#                  priority):
#         """
#         @param match_values A map from match fields to values
#         @param match_masks A map from match fields to masks for comparing
#         @param action_ref The name of the action to execute
#         @param action_params Map from parameter name to value
#         @param priority The priority of the entry
# 
#         Higher numbers are higher priority
#         """
#         meta_ir_assert(match_masks is None or isinstance(match_masks, dict),
#                    "Bad mask parameter to table_entry initializer")
#         TableEntryBase.__init__(self, action_ref, action_params)
#         self.match_masks = match_masks
#         self.match_values = match_values
#         self.priority = priority
# 
# 
#     def check_match(self, parsed_packet):
#         """
#         @brief Check if packet matches this entry
#         @return (action_name, action_param_map) if match; None otherwise
#         """
#         for field_name, value in self.match_values.items():
#             mask = deref_or_none(self.match_masks, field_name)
#             p_value = parsed_packet.get_field(field_name)
#             if p_value is None:
#                 return None
#             if mask is not None:
#                 if p_value & mask != value & mask:
#                     return None
#             else:
#                 if p_value != value:
#                     return None
# 
#         return (self.action_ref, self.action_params)
# 
# Path: pif_ir/air/objects/table_entry.py
# class TableEntryDefault(TableEntryBase):
#     """
#     Entry object for a default match. Same as TableEntryBase
#     """
#     pass


# Path: pif_ir/air/objects/table.py
import sys
from threading import Condition
from pif_ir.meta_ir.common import *
from pif_ir.air.objects.table_entry import TableEntryExact
from pif_ir.air.objects.table_entry import TableEntryTernary
from pif_ir.air.objects.table_entry import TableEntryDefault

            pass
        else:
            raise AirReferenceError("Unknown entry ref type for entry remove")

    def clear(self, clear_stats=True, clear_default=False):
        """
        Remove all entries from the table
        @param clear_stats If True, set table counters to 0
        @param clear_default If True, clear the default entry too
        """
        logging.debug("Clearing table %s" % self.name)
        with self.cond_var:
            if clear_stats:
                self.packet_count = 0
                self.byte_count = 0
            for entry in self.entries:
                # For now, do nothing
                pass
            self.entries = []
            if clear_default:
                self.default_entry = None

    def hit_stats(self):
        """
        @brief Return table counters
        @returns A pair of integers, byte count and packet count
        """
        return (self.byte_count, self.packet_count)

    def set_default_entry(self, entry):

        meta_ir_assert(isinstance(entry, TableEntryDefault))