;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; LUSH Lisp Universal Shell
;;;   Copyright (C) 2002 Leon Bottou, Yann Le Cun, AT&T Corp, NECI.
;;; Includes parts of TL3:
;;;   Copyright (C) 1987-1999 Leon Bottou and Neuristique.
;;; Includes selected parts of SN3.2:
;;;   Copyright (C) 1991-2001 AT&T Corp.
;;;
;;; Includes information derived from the GSL (Gnu Scientific Library)
;;;   header files which are copyrighted and distributed under the GPL
;;;   by their respective authors.
;;;
;;; 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, USA
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(libload "inventor/inventor-config")



#? *** sensors

;; dummy function that adds inventor header files in C file
(eval `(de |dummy_sensors| () ,inventor-cpheader-cmd ()))

#? * sosensor
;;.TYPE CLASS
#? (==> <sosensor> setfunction <f>)
#? (==> <sosensor> setdata <d>)
#? (==> <sosensor> getfunction)
#? (==> <sosensor> getdata)

#? * sotimerqueuesensor
;;.TYPE CLASS
#? (new sotimerqueuesensor <flag>>
#? (==> <sotimerqueuesensor> -destructor)
#? (==> <sotimerqueuesensor> gettriggertime)
#? (==> <sotimerqueuesensor> schedule)
#? (==> <sotimerqueuesensor> unschedule)
#? (==> <sotimerqueuesensor> isscheduled)

#? * sodelayqueuesensor
;;.TYPE CLASS
#? (new sodelayqueuesensor <flag>>
#? (==> <sodelayqueuesensor> -destructor)
#? (==> <sodelayqueuesensor> setpriority <pri>)
#? (==> <sodelayqueuesensor> getpriority)
#? (==> <sodelayqueuesensor> schedule)
#? (==> <sodelayqueuesensor> unschedule)
#? (==> <sodelayqueuesensor> isscheduled)
#? (==> <sodelayqueuesensor> isidleonly)

#? * soalarmsensor
;;.TYPE CLASS
#? (new soalarmsensor <flag>>
#? (==> <soalarmsensor> -destructor)
#? (==> <soalarmsensor> settime <abstime>)
#? (==> <soalarmsensor> settimefromnow <reltime>)
#? (==> <soalarmsensor> gettime)
#? (==> <soalarmsensor> schedule)

#? * sodatasensor
;;.TYPE CLASS
#? (==> <sodatasensor> setdeletecallback <func> <data>)
#? (==> <sodatasensor> gettriggernode)
#? (==> <sodatasensor> gettriggerfield)
#? (==> <sodatasensor> gettriggerpath)
#? (==> <sodatasensor> settriggerpathflag <flag>)
#? (==> <sodatasensor> gettriggerpathflag)
#? (==> <sodatasensor> unschedule)

#? * soidlesensor
;;.TYPE CLASS
#? (new soidlesensor <flag>>
#? (==> <soidlesensor> -destructor)

#? * sonodesensor
;;.TYPE CLASS
#? (new sonodesensor <flag> <func> <data>)
#? (==> <sonodesensor> -destructor)
#? (==> <sonodesensor> attach <node>)
#? (==> <sonodesensor> detach)
#? (==> <sonodesensor> getattachednode)

#? * sofieldsensor
;;.TYPE CLASS
#? (new sofieldsensor <flag> <func> <data>)
#? (==> <sofieldsensor> -destructor)
#? (==> <sofieldsensor> attach <field>)
#? (==> <sofieldsensor> detach)
#? (==> <sofieldsensor> getattachedfield)

#? * sooneshotsensor
;;.TYPE CLASS
#? (new sooneshotsensor <flag>)
#? (==> <sooneshotsensor> -destructor)

#? * sopathsensor
;;.TYPE CLASS
#? (new sopathsensor <flag>)
#? (==> <sopathsensor> -destructor)
#? (==> <sopathsensor> attach <path>)
#? (==> <sopathsensor> detach)
#? (==> <sopathsensor> getattachedpath)

#? * sotimersensor
;;.TYPE CLASS
#? (new sotimersensor <flag>)
#? (==> <sotimersensor> -destructor)
#? (==> <sotimersensor> setbasetime <base>)
#? (==> <sotimersensor> setinterval <intvl>)
#? (==> <sotimersensor> getbasetime)
#? (==> <sotimersensor> getinterval)
#? (==> <sotimersensor> schedule)
#? (==> <sotimersensor> unschedule)

#? * (|dummy_sensors|)

;; ********************************************************




;;************************************************************
;;**********  sensors
;;************************************************************
(libload "inventor/sotype")


;; class SoSensor : public InventorObject **abstract**
(defclass SoSensor InventorObject)

(defmethod SoSensor  setFunction ( f)
  
  ((-gptr- "SoSensorCB *") f)
  #{ ((SoSensor *)$p)->setFunction($f);  #} 
  ())

(defmethod SoSensor  setData ( d)
  
  ((-gptr-) d)
  #{ ((SoSensor *)$p)->setData($d);  #} 
  ())

(defmethod SoSensor  getFunction (  )
  
  (gptr #{ ((SoSensor *)$p)->getFunction()  #} ))    ;; SoSensorCB *  -> gptr

(defmethod SoSensor  getData (  )
  
  (gptr #{ ((SoSensor *)$p)->getData()  #} ))    


;; class SoTimerQueueSensor : public SoSensor
(defclass SoTimerQueueSensor SoSensor)

(defmethod SoTimerQueueSensor  SoTimerQueueSensor ( flag  )
  ((-bool-) flag)
  
  #{  if($flag == false ) {
            $p = new  SoTimerQueueSensor;
            $shell_flag = false;
      }
      else
            $shell_flag = true;
  #} 
  ())

;; (defmethod SoTimerQueueSensor  SoTimerQueueSensor ( flag func data)
;;   ((-bool-) flag)
;;   
;;   ((-gptr- "SoSensorCB *") func)
;;   ((-gptr-) data)
;;   #{  if($flag == false ) {
;;             $p = new  SoTimerQueueSensor($func, $data)x;
;;             $shell_flag = false;
;;       }
;;       else
;;             $shell_flag = true;
;;   #} 
;;   ())

(defmethod SoTimerQueueSensor -destructor (  )
  
  #{   if($shell_flag == false ) {
             delete  ((SoTimerQueueSensor *)$p);
             $p = NULL;
             $shell_flag = true;
       }
  #} 
  ())

(defmethod SoTimerQueueSensor  getTriggerTime (  )
  
  (gptr #{ &(((SoTimerQueueSensor *)$p)->getTriggerTime())  #} ))  ;; const SbTime & -> gptr

(defmethod SoTimerQueueSensor  schedule (  )
  
  #{ ((SoTimerQueueSensor *)$p)->schedule();  #} 
  ())

(defmethod SoTimerQueueSensor  unschedule (  )
  
  #{ ((SoTimerQueueSensor *)$p)->unschedule();  #} 
  ())

(defmethod SoTimerQueueSensor  isScheduled (  )
  
  (int #{ ((SoTimerQueueSensor *)$p)->isScheduled()  #} ))




;; class SoDelayQueueSensor : public SoSensor
(defclass SoDelayQueueSensor SoSensor)

(defmethod SoDelayQueueSensor  SoDelayQueueSensor ( flag  )
  ((-bool-) flag)
  
  #{  if($flag == false ) {
            $p = new  SoDelayQueueSensor;
            $shell_flag = false;
      }
      else
            $shell_flag = true;
  #} 
  ())

;; (defmethod SoDelayQueueSensor  SoDelayQueueSensor ( flag func data)
;;   ((-bool-) flag)
;;   
;;   ((-gptr- "SoSensorCB *") func)
;;   ((-gptr-) data)
;;   #{  if($flag == false ) {
;;             $p = new  SoDelayQueueSensor($func, $data);
;;             $shell_flag = false;
;;       }
;;       else
;;             $shell_flag = true;
;;   #} 
;;   ())

(defmethod SoDelayQueueSensor -destructor (  )
  
  #{   if($shell_flag == false ) {
             delete  ((SoDelayQueueSensor *)$p);
             $p = NULL;
             $shell_flag = true;
       }
  #} 
  ())

(defmethod SoDelayQueueSensor  setPriority ( pri)
  
  ((-int-) pri)    ;; uint32_t -> int
  #{ ((SoDelayQueueSensor *)$p)->setPriority($pri);  #} 
  ())

(defmethod SoDelayQueueSensor  getPriority (  )
  
  (int #{ ((SoDelayQueueSensor *)$p)->getPriority()  #} )) ;; uint32_t -> int

(defmethod SoDelayQueueSensor  schedule (  )
  
  #{ ((SoDelayQueueSensor *)$p)->schedule();  #} 
  ())

(defmethod SoDelayQueueSensor  unschedule (  )
  
  #{ ((SoDelayQueueSensor *)$p)->unschedule();  #} 
  ())

(defmethod SoDelayQueueSensor  isScheduled (  )
  
  (int #{ ((SoDelayQueueSensor *)$p)->isScheduled()  #} ))

(defmethod SoDelayQueueSensor  isIdleOnly (  )
  
  (int #{ ((SoDelayQueueSensor *)$p)->isIdleOnly()  #} ))




;; class SoAlarmSensor : public SoTimerQueueSensor    
(defclass SoAlarmSensor SoTimerQueueSensor)

(defmethod SoAlarmSensor  SoAlarmSensor ( flag  )
  ((-bool-) flag)
  
  #{  if($flag == false ) {
            $p = new  SoAlarmSensor;
            $shell_flag = false;
      }
      else
            $shell_flag = true;
  #} 
  ())

;; (defmethod SoAlarmSensor  SoAlarmSensor ( flag  func data )
;;   ((-bool-) flag)
;;   
;;   ((-gptr- "SoSensorCB *") func)
;;   ((-gptr-) data)
;;   #{  if($flag == false ) {
;;             $p = new  SoAlarmSensor($func, $data);
;;             $shell_flag = false;
;;       }
;;       else
;;             $shell_flag = true;
;;   #} 
;;   ())

(defmethod SoAlarmSensor -destructor (  )
  
  #{   if($shell_flag == false ) {
             delete  ((SoAlarmSensor *)$p);
             $p = NULL;
             $shell_flag = true;
       }
  #} 
  ())

(defmethod SoAlarmSensor  setTime (  absTime )
  
  ((-gptr- "const SbTime *") absTime)  ;; reference -> gptr
  #{ ((SoAlarmSensor *)$p)->setTime(*$absTime);  #} 
  ())

(defmethod SoAlarmSensor  setTimeFromNow (  relTime )
  
  ((-gptr- "const SbTime *") relTime)   ;; reference -> gptr
  #{ ((SoAlarmSensor *)$p)->setTimeFromNow(*$relTime);  #} 
  ())

(defmethod SoAlarmSensor  getTime (  )
  
  (gptr #{ &(((SoAlarmSensor *)$p)->getTime())  #} ))  ;; const SbTime & -> gptr

(defmethod SoAlarmSensor  schedule (  )
  
  #{ ((SoAlarmSensor *)$p)->schedule();  #} 
  ())





;; class SoDataSensor : public SoDelayQueueSensor
(defclass SoDataSensor SoDelayQueueSensor)

(defmethod SoDataSensor  setDeleteCallback ( func data)
  
  ((-gptr- "SoSensorCB *") func)
  ((-gptr-) data)
  #{ ((SoDataSensor *)$p)->setDeleteCallback($func,$data);  #} 
  ())

(defmethod SoDataSensor  getTriggerNode (  )
  
  (gptr #{ ((SoDataSensor *)$p)->getTriggerNode()  #} ))    ;; SoNode *  -> gptr

(defmethod SoDataSensor  getTriggerField (  )
  
  (gptr #{ ((SoDataSensor *)$p)->getTriggerField()  #} ))    ;; SoField *  -> gptr

(defmethod SoDataSensor  getTriggerPath (  )
  
  (gptr #{ ((SoDataSensor *)$p)->getTriggerPath()  #} ))    ;; SoPath *  -> gptr

(defmethod SoDataSensor  setTriggerPathFlag ( flag)
  
  ((-int-) flag)                    ;; SbBool -> int
  #{ ((SoDataSensor *)$p)->setTriggerPathFlag($flag);  #} 
  ())

(defmethod SoDataSensor  getTriggerPathFlag (  )
  
  (int #{ ((SoDataSensor *)$p)->getTriggerPathFlag()  #} ))

(defmethod SoDataSensor  unschedule (  )
  
  #{ ((SoDataSensor *)$p)->unschedule();  #} 
  ())






;; class SoIdleSensor : public SoDelayQueueSensor
(defclass SoIdleSensor SoDelayQueueSensor)

(defmethod SoIdleSensor  SoIdleSensor ( flag  )
  ((-bool-) flag)
  
  #{  if($flag == false ) {
            $p = new  SoIdleSensor;
            $shell_flag = false;
      }
      else
            $shell_flag = true;
  #} 
  ())

;; (defmethod SoIdleSensor  SoIdleSensor ( flag func data)
;;   ((-bool-) flag)
;;   
;;   ((-gptr- "SoSensorCB *") func)
;;   ((-gptr-) data)
;;   #{  if($flag == false ) {
;;             $p = new  SoIdleSensor($func, $data);
;;             $shell_flag = false;
;;       }
;;       else
;;             $shell_flag = true;
;;   #} 
;;   ())

(defmethod SoIdleSensor -destructor (  )
  
  #{   if($shell_flag == false ) {
             delete  ((SoIdleSensor *)$p);
             $p = NULL;
             $shell_flag = true;
       }
  #} 
  ())



;; class SoNodeSensor : public SoDataSensor
(defclass SoNodeSensor SoDataSensor)

;;(defmethod SoNodeSensor  SoNodeSensor ( flag  )
;;  ((-bool-) flag)
  
;;  #{  if($flag == false ) {
;;            $p = new  SoNodeSensor;
;;            $shell_flag = false;
;;      }
;;      else
;;            $shell_flag = true;
;;  #} 
;;  ())

(defmethod SoNodeSensor  SoNodeSensor ( flag func data)
  ((-bool-) flag)
   
  ((-gptr- "SoSensorCB *") func)
  ((-gptr-) data)
  #{  if($flag == false ) {
             $p = new  SoNodeSensor($func, $data);
             $shell_flag = false;
       }
       else
             $shell_flag = true;
  #} 
  ())

(defmethod SoNodeSensor -destructor (  )
  
  #{   if($shell_flag == false ) {
             delete  ((SoNodeSensor *)$p);
             $p = NULL;
             $shell_flag = true;
       }
  #} 
  ())

(defmethod SoNodeSensor  attach ( node)
  
  ((-gptr- "SoNode *") node)
  #{ ((SoNodeSensor *)$p)->attach($node);  #} 
  ())

(defmethod SoNodeSensor  detach (  )
  
  #{ ((SoNodeSensor *)$p)->detach();  #} 
  ())

(defmethod SoNodeSensor  getAttachedNode (  )
  
  (gptr #{ ((SoNodeSensor *)$p)->getAttachedNode()  #} ))    ;; SoNode *  -> gptr


;; class SoFieldSensor : public SoDataSensor
(defclass SoFieldSensor SoDataSensor)

;;(defmethod SoFieldSensor  SoFieldSensor ( flag  )
;;  ((-bool-) flag)
  
;;  #{  if($flag == false ) {
;;            $p = new  SoFieldSensor;
;;            $shell_flag = false;
;;      }
;;      else
;;            $shell_flag = true;
;;  #} 
;;  ())

(defmethod SoFieldSensor  SoFieldSensor ( flag func data)
  ((-bool-) flag)
   
  ((-gptr- "SoSensorCB *") func)
  ((-gptr-) data)
  #{  if($flag == false ) {
             $p = new  SoFieldSensor($func, $data);
             $shell_flag = false;
       }
       else
             $shell_flag = true;
  #} 
  ())

(defmethod SoFieldSensor -destructor (  )
  
  #{   if($shell_flag == false ) {
             delete  ((SoFieldSensor *)$p);
             $p = NULL;
             $shell_flag = true;
       }
  #} 
  ())

(defmethod SoFieldSensor  attach ( field)
  
  ((-gptr- "SoField *") field)
  #{ ((SoFieldSensor *)$p)->attach($field);  #} 
  ())

(defmethod SoFieldSensor  detach (  )
  
  #{ ((SoFieldSensor *)$p)->detach();  #} 
  ())

(defmethod SoFieldSensor  getAttachedField (  )
  
  (gptr #{ ((SoFieldSensor *)$p)->getAttachedField()  #} ))    ;; SoField *  -> gptr



;; class SoOneShotSensor : public SoDelayQueueSensor
(defclass SoOneShotSensor SoDelayQueueSensor)

(defmethod SoOneShotSensor  SoOneShotSensor ( flag  )
  ((-bool-) flag)
  
  #{  if($flag == false ) {
            $p = new  SoOneShotSensor;
            $shell_flag = false;
      }
      else
            $shell_flag = true;
  #} 
  ())

;; (defmethod SoOneShotSensor  SoOneShotSensor ( flag func data)
;;   ((-bool-) flag)
;;   
;;   ((-gptr- "SoSensorCB *") func)
;;   ((-gptr-) data)
;;   #{  if($flag == false ) {
;;             $p = new  SoOneShotSensor($func, $data);
;;             $shell_flag = false;
;;       }
;;       else
;;             $shell_flag = true;
;;   #} 
;;   ())

(defmethod SoOneShotSensor -destructor (  )
  
  #{   if($shell_flag == false ) {
             delete  ((SoOneShotSensor *)$p);
             $p = NULL;
             $shell_flag = true;
       }
  #} 
  ())






;; class SoPathSensor : public SoDataSensor
(defclass SoPathSensor SoDataSensor)

(defmethod SoPathSensor  SoPathSensor ( flag  )
  ((-bool-) flag)
  
  #{  if($flag == false ) {
            $p = new  SoPathSensor;
            $shell_flag = false;
      }
      else
            $shell_flag = true;
  #} 
  ())

;; (defmethod SoPathSensor  SoPathSensor ( flag func data)
;;   ((-bool-) flag)
;;   
;;   ((-gptr- "SoSensorCB *") func)
;;   ((-gptr-) data)
;;   #{  if($flag == false ) {
;;             $p = new  SoPathSensor($func, $data);
;;             $shell_flag = false;
;;       }
;;       else
;;             $shell_flag = true;
;;   #} 
;;   ())

(defmethod SoPathSensor -destructor (  )
  
  #{   if($shell_flag == false ) {
             delete  ((SoPathSensor *)$p);
             $p = NULL;
             $shell_flag = true;
       }
  #} 
  ())

(defmethod SoPathSensor  attach ( path)
  
  ((-gptr- "SoPath *") path)
  #{ ((SoPathSensor *)$p)->attach($path);  #} 
  ())

(defmethod SoPathSensor  detach (  )
  
  #{ ((SoPathSensor *)$p)->detach();  #} 
  ())

(defmethod SoPathSensor  getAttachedPath (  )
  
  (gptr #{ ((SoPathSensor *)$p)->getAttachedPath()  #} ))    ;; SoPath *  -> gptr







;; class SoTimerSensor : public SoTimerQueueSensor
(defclass SoTimerSensor SoTimerQueueSensor)

;; (defmethod SoTimerSensor  SoTimerSensor ( flag  )
;;  ((-bool-) flag)
;;  
;;  #{  if($flag == false ) {
;;            $p = new  SoTimerSensor;
;;            $shell_flag = false;
;;      }
;;      else
;;            $shell_flag = true;
;;  #} 
;;  ())

(defmethod SoTimerSensor  SoTimerSensor ( flag func data)
  ((-bool-) flag)
  
  ((-gptr- "SoSensorCB *") func)
  ((-gptr-) data)
  #{  if($flag == false ) {
           $p = new  SoTimerSensor($func, $data);
           $shell_flag = false;
      }
      else
           $shell_flag = true;
  #} 
  ())

(defmethod SoTimerSensor -destructor (  )
  
  #{   if($shell_flag == false ) {
             delete  ((SoTimerSensor *)$p);
             $p = NULL;
             $shell_flag = true;
       }
  #} 
  ())

(defmethod SoTimerSensor  setBaseTime ( base)
  
  ((-gptr- "const SbTime *") base)   ;; reference -> gptr
  #{ ((SoTimerSensor *)$p)->setBaseTime(*$base);  #} 
  ())

(defmethod SoTimerSensor  setInterval ( intvl)
  
  ((-gptr- "const SbTime *") intvl)   ;; reference -> gptr
  #{ ((SoTimerSensor *)$p)->setInterval(*$intvl);  #} 
  ())

(defmethod SoTimerSensor  getBaseTime (  )
  
  (gptr #{ &(((SoTimerSensor *)$p)->getBaseTime())  #} ))  ;; const SbTime & -> gptr

(defmethod SoTimerSensor  getInterval (  )
  
  (gptr #{ &(((SoTimerSensor *)$p)->getInterval())  #} ))  ;; const SbTime & -> gptr

(defmethod SoTimerSensor  schedule (  )
  
  #{ ((SoTimerSensor *)$p)->schedule();  #} 
  ())

(defmethod SoTimerSensor  unschedule (  )
  
  #{ ((SoTimerSensor *)$p)->unschedule();  #} 
  ())




;; ********************************************************

(dhc-make-with-c++ () () 
  |dummy_sensors|
  (sosensor  getdata  getfunction  setdata  setfunction)
  (sotimerqueuesensor  isscheduled  unschedule  schedule  gettriggertime  -destructor  sotimerqueuesensor)
  (sodelayqueuesensor  isidleonly  isscheduled  unschedule  schedule  getpriority  setpriority  -destructor  sodelayqueuesensor)
  (soalarmsensor  schedule  gettime  settimefromnow  settime  -destructor  soalarmsensor)
  (sodatasensor  unschedule  gettriggerpathflag  settriggerpathflag  gettriggerpath  gettriggerfield  gettriggernode  setdeletecallback)
  (soidlesensor  -destructor  soidlesensor)
  (sonodesensor  getattachednode  detach  attach  -destructor  sonodesensor)
  (sofieldsensor getattachedfield detach  attach  -destructor  sofieldsensor)
  (sooneshotsensor  -destructor  sooneshotsensor)
  (sopathsensor  getattachedpath  detach  attach  -destructor  sopathsensor)
  (sotimersensor  unschedule  schedule  getinterval  getbasetime  setinterval  setbasetime  -destructor  sotimersensor)
)
