(*
This file is part of the dpll(t) engine sammy
Copyright (C) 2005  The University of Iowa
Mike Decoster
George Hagen

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*)

exception Modified_an_unmodifiable_annotation

class label (str, modifiable : string*bool) =
  
  let label_data=
            if str  =  "" then 
              None
            else 
              Some(str)
  in
object (self)
  val mutable formula_depth : int = 0
  val mutable preferred_polarity : Global.status = Global.Unsat
  val mutable guard : bool = false
  method is_modifiable = modifiable
  method get_label = 
            match label_data with
              None -> ""
            | Some(str) -> str
  method is_empty =
            match label_data with
              None -> true
            | _ -> false
  method is_guard = guard
  method set_guard new_guard = 
          if not modifiable then 
            raise Modified_an_unmodifiable_annotation
          else
            guard <- new_guard
end

let empty_label = new label("",false);;

let newlabel str = new label(str,true);;

let set_label_guard label guard =
  if label#is_guard   =   guard then
    label
  else
  begin
    if label  =  empty_label then
    begin
      let new_label=new label("",true) in
      new_label#set_guard guard;
      new_label
    end
    else
    begin
      label#set_guard guard;
      label
    end
  end
  
