"""
   /*
   **   Generated by blitz/resources/templates/combined.vm
   **
   **   Copyright 2007, 2008 Glencoe Software, Inc. All rights reserved.
   **   Use is subject to license terms supplied in LICENSE.txt
   **
   */
"""
import Ice
import IceImport
import omero
IceImport.load("omero_model_DetailsI")
IceImport.load("omero_model_ProjectionDef_ice")
from omero.rtypes import rlong
from collections import namedtuple
_omero = Ice.openModule("omero")
_omero_model = Ice.openModule("omero.model")
__name__ = "omero.model"
class ProjectionDefI(_omero_model.ProjectionDef):

      # Property Metadata
      _field_info_data = namedtuple("FieldData", ["wrapper", "nullable"])
      _field_info_type = namedtuple("FieldInfo", [
          "renderingDef",
          "axis",
          "type",
          "active",
          "startPlane",
          "endPlane",
          "stepping",
          "details",
      ])
      _field_info = _field_info_type(
          renderingDef=_field_info_data(wrapper=omero.proxy_to_instance, nullable=False),
          axis=_field_info_data(wrapper=omero.proxy_to_instance, nullable=False),
          type=_field_info_data(wrapper=omero.proxy_to_instance, nullable=False),
          active=_field_info_data(wrapper=omero.rtypes.rbool, nullable=False),
          startPlane=_field_info_data(wrapper=omero.rtypes.rint, nullable=True),
          endPlane=_field_info_data(wrapper=omero.rtypes.rint, nullable=True),
          stepping=_field_info_data(wrapper=omero.rtypes.rint, nullable=True),
          details=_field_info_data(wrapper=omero.proxy_to_instance, nullable=True),
      )  # end _field_info
      RENDERINGDEF =  "ome.model.display.ProjectionDef_renderingDef"
      AXIS =  "ome.model.display.ProjectionDef_axis"
      TYPE =  "ome.model.display.ProjectionDef_type"
      ACTIVE =  "ome.model.display.ProjectionDef_active"
      STARTPLANE =  "ome.model.display.ProjectionDef_startPlane"
      ENDPLANE =  "ome.model.display.ProjectionDef_endPlane"
      STEPPING =  "ome.model.display.ProjectionDef_stepping"
      DETAILS =  "ome.model.display.ProjectionDef_details"
      def errorIfUnloaded(self):
          if not self._loaded:
              raise _omero.UnloadedEntityException("Object unloaded:"+str(self))

      def throwNullCollectionException(self,propertyName):
          raise _omero.UnloadedEntityException(""+
          "Error updating collection:" + propertyName +"\n"+
          "Collection is currently null. This can be seen\n" +
          "by testing \""+ propertyName +"Loaded\". This implies\n"+
          "that this collection was unloaded. Please refresh this object\n"+
          "in order to update this collection.\n")

      def _toggleCollectionsLoaded(self, load):
          pass

      def __init__(self, id=None, loaded=None):
          super(ProjectionDefI, self).__init__()
          if id is not None and isinstance(id, (str, unicode)) and ":" in id:
              parts = id.split(":")
              if len(parts) != 2:
                  raise Exception("Invalid proxy string: %s", id)
              if parts[0] != self.__class__.__name__ and \
                 parts[0]+"I" != self.__class__.__name__:
                  raise Exception("Proxy class mismatch: %s<>%s" %
                  (self.__class__.__name__, parts[0]))
              self._id = rlong(parts[1])
              if loaded is None:
                  # If no loadedness was requested with
                  # a proxy string, then assume False.
                  loaded = False
          else:
              # Relying on omero.rtypes.rlong's error-handling
              self._id = rlong(id)
              if loaded is None:
                  loaded = True  # Assume true as previously
          self._loaded = loaded
          if self._loaded:
             self._details = _omero_model.DetailsI()
             self._toggleCollectionsLoaded(True)

      def unload(self, current = None):
          self._loaded = False
          self.unloadRenderingDef( )
          self.unloadAxis( )
          self.unloadType( )
          self.unloadActive( )
          self.unloadStartPlane( )
          self.unloadEndPlane( )
          self.unloadStepping( )
          self.unloadDetails( )

      def isLoaded(self, current = None):
          return self._loaded
      def unloadCollections(self, current = None):
          self._toggleCollectionsLoaded( False )
      def isGlobal(self, current = None):
          return  False ;
      def isMutable(self, current = None):
          return  True ;
      def isAnnotated(self, current = None):
          return  False ;
      def isLink(self, current = None):
          return  False ;
      def shallowCopy(self, current = None):
            if not self._loaded: return self.proxy()
            copy = ProjectionDefI()
            copy._id = self._id;
            copy._version = self._version;
            copy._details = None  # Unloading for the moment.
            raise omero.ClientError("NYI")
      def proxy(self, current = None):
          if self._id is None: raise omero.ClientError("Proxies require an id")
          return ProjectionDefI( self._id.getValue(), False )

      def getDetails(self, current = None):
          self.errorIfUnloaded()
          return self._details

      def unloadDetails(self, current = None):
          self._details = None

      def getId(self, current = None):
          return self._id

      def setId(self, _id, current = None):
          self._id = _id

      def checkUnloadedProperty(self, value, loadedField):
          if value == None:
              self.__dict__[loadedField] = False
          else:
              self.__dict__[loadedField] = True

      def getVersion(self, current = None):
          self.errorIfUnloaded()
          return self._version

      def setVersion(self, version, current = None):
          self.errorIfUnloaded()
          self._version = version

      def unloadRenderingDef(self, ):
          self._renderingDefLoaded = False
          self._renderingDef = None;

      def getRenderingDef(self, current = None):
          self.errorIfUnloaded()
          return self._renderingDef

      def setRenderingDef(self, _renderingDef, current = None, wrap=False):
          self.errorIfUnloaded()
          if wrap and self._field_info.renderingDef.wrapper is not None:
              if _renderingDef is not None:
                  _renderingDef = self._field_info.renderingDef.wrapper(_renderingDef)
          self._renderingDef = _renderingDef
          pass

      def unloadAxis(self, ):
          self._axisLoaded = False
          self._axis = None;

      def getAxis(self, current = None):
          self.errorIfUnloaded()
          return self._axis

      def setAxis(self, _axis, current = None, wrap=False):
          self.errorIfUnloaded()
          if wrap and self._field_info.axis.wrapper is not None:
              if _axis is not None:
                  _axis = self._field_info.axis.wrapper(_axis)
          self._axis = _axis
          pass

      def unloadType(self, ):
          self._typeLoaded = False
          self._type = None;

      def getType(self, current = None):
          self.errorIfUnloaded()
          return self._type

      def setType(self, _type, current = None, wrap=False):
          self.errorIfUnloaded()
          if wrap and self._field_info.type.wrapper is not None:
              if _type is not None:
                  _type = self._field_info.type.wrapper(_type)
          self._type = _type
          pass

      def unloadActive(self, ):
          self._activeLoaded = False
          self._active = None;

      def getActive(self, current = None):
          self.errorIfUnloaded()
          return self._active

      def setActive(self, _active, current = None, wrap=False):
          self.errorIfUnloaded()
          if wrap and self._field_info.active.wrapper is not None:
              if _active is not None:
                  _active = self._field_info.active.wrapper(_active)
          self._active = _active
          pass

      def unloadStartPlane(self, ):
          self._startPlaneLoaded = False
          self._startPlane = None;

      def getStartPlane(self, current = None):
          self.errorIfUnloaded()
          return self._startPlane

      def setStartPlane(self, _startPlane, current = None, wrap=False):
          self.errorIfUnloaded()
          if wrap and self._field_info.startPlane.wrapper is not None:
              if _startPlane is not None:
                  _startPlane = self._field_info.startPlane.wrapper(_startPlane)
          self._startPlane = _startPlane
          pass

      def unloadEndPlane(self, ):
          self._endPlaneLoaded = False
          self._endPlane = None;

      def getEndPlane(self, current = None):
          self.errorIfUnloaded()
          return self._endPlane

      def setEndPlane(self, _endPlane, current = None, wrap=False):
          self.errorIfUnloaded()
          if wrap and self._field_info.endPlane.wrapper is not None:
              if _endPlane is not None:
                  _endPlane = self._field_info.endPlane.wrapper(_endPlane)
          self._endPlane = _endPlane
          pass

      def unloadStepping(self, ):
          self._steppingLoaded = False
          self._stepping = None;

      def getStepping(self, current = None):
          self.errorIfUnloaded()
          return self._stepping

      def setStepping(self, _stepping, current = None, wrap=False):
          self.errorIfUnloaded()
          if wrap and self._field_info.stepping.wrapper is not None:
              if _stepping is not None:
                  _stepping = self._field_info.stepping.wrapper(_stepping)
          self._stepping = _stepping
          pass


      def ice_postUnmarshal(self):
          """
          Provides additional initialization once all data loaded
          """
          pass # Currently unused


      def ice_preMarshal(self):
          """
          Provides additional validation before data is sent
          """
          pass # Currently unused

      def __getattr__(self, name):
          import __builtin__
          """
          Reroutes all access to object.field through object.getField() or object.isField()
          """
          if "_" in name:  # Ice disallows underscores, so these should be treated normally.
              return object.__getattribute__(self, name)
          field  = "_" + name
          capitalized = name[0].capitalize() + name[1:]
          getter = "get" + capitalized
          questn = "is" + capitalized
          try:
              self.__dict__[field]
              if hasattr(self, getter):
                  method = getattr(self, getter)
                  return method()
              elif hasattr(self, questn):
                  method = getattr(self, questn)
                  return method()
          except:
              pass
          raise AttributeError("'%s' object has no attribute '%s' or '%s'" % (self.__class__.__name__, getter, questn))

      def __setattr__(self, name, value):
          """
          Reroutes all access to object.field through object.getField(), with the caveat
          that all sets on variables starting with "_" are permitted directly.
          """
          if name.startswith("_"):
              self.__dict__[name] = value
              return
          else:
              field  = "_" + name
              setter = "set" + name[0].capitalize() + name[1:]
              if hasattr(self, field) and hasattr(self, setter):
                  method = getattr(self, setter)
                  return method(value)
          raise AttributeError("'%s' object has no attribute '%s'" % (self.__class__.__name__, setter))

_omero_model.ProjectionDefI = ProjectionDefI
