2 # -*- coding: utf-8 -*-
4 # codimension - graphics python two-way code editor and analyzer
5 # Copyright (C) 2010-2012 Sergey Satskiy <sergey.satskiy@gmail.com>
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
23 " Debugger watchpoint "
26 from utils
.globals import GlobalData
30 " Represents a single watchpoint "
32 def __init__( self
, condition
= None, special
= False,
33 temporary
= False, enabled
= True, ignoreCount
= 0 ):
35 self
.__condition
= condition
36 self
.__special
= special
37 self
.__temporary
= temporary
38 self
.__enabled
= enabled
39 self
.__ignoreCount
= 0
44 " True if the watchpoint is valid "
45 return self
.__condition
is not None
47 def getSpecial( self
):
48 " Provides the special "
51 def getCondition( self
):
52 " Provides the condition "
53 return self
.__condition
55 def isTemporary( self
):
57 return self
.__temporary
59 def isEnabled( self
):
63 def getIgnoreCount( self
):
64 " Provides the ignore count "
65 return self
.__ignoreCount
67 def serialize( self
):
68 " Serializes the watchpoint to a string "
69 return ":::".join( [ str( self
.__condition
), str( self
.__special
),
70 str( self
.__temporary
),
71 str( self
.__enabled
), str( self
.__ignoreCount
) ] )
73 def deserialize( self
, source
):
74 " Deserializes the watchpoint "
75 parts
= source
.split( ":::" )
77 raise Exception( "Unexpected number of fields" )
79 if parts
[ 0 ] == "None":
80 self
.__condition
= None
82 self
.__condition
= parts
[ 0 ]
84 if parts
[ 1 ] == "True":
87 self
.__special
= False
89 if parts
[ 2 ] == "True":
90 self
.__temporary
= True
92 self
.__temporary
= False
94 if parts
[ 3 ] == "True":
97 self
.__enabled
= False
99 self
.__ignoreCount
= int( parts
[ 4 ] )
101 return self
.isValid()