diff src/ov-fcn-handle.h @ 4925:90f51232d751

[project @ 2004-08-02 22:09:47 by jwe]
author jwe
date Mon, 02 Aug 2004 22:09:47 +0000
parents 9a3a32f5a27d
children bdb307dc8613
line wrap: on
line diff
--- a/src/ov-fcn-handle.h	Mon Aug 02 19:04:20 2004 +0000
+++ b/src/ov-fcn-handle.h	Mon Aug 02 22:09:47 2004 +0000
@@ -40,114 +40,18 @@
 
 // Function handles.
 
-class fcn_handle_elt
-{
-public:
-
-  fcn_handle_elt (void) : fcn (0), nm ("@[]") { }
-
-  fcn_handle_elt (octave_function *f, const std::string& n)
-    : fcn (f), nm (std::string ("@") + n) { }
-
-  fcn_handle_elt (const fcn_handle_elt& fhe)
-    : fcn (fhe.fcn), nm (fhe.nm) { }
-
-  fcn_handle_elt& operator = (const fcn_handle_elt& fhe)
-    {
-      if (this != &fhe)
-	{
-	  fcn = fhe.fcn;
-	  nm  = fhe.nm;
-	}
-
-      return *this;
-    }
-
-  ~fcn_handle_elt (void) { }
-
-  octave_function *function_value (void) { return fcn; }
-
-  std::string name (void) const { return nm; }
-
-private:
-
-  // The function we are handling.
-  octave_function *fcn;
-
-  // The name of the handle, including the "@".
-  std::string nm;
-};
-
-class fcn_handle_array : public ArrayN<fcn_handle_elt>
+class
+octave_fcn_handle : public octave_base_value
 {
 public:
 
-  fcn_handle_array (void) : ArrayN<fcn_handle_elt> () { }
-
-  fcn_handle_array (const dim_vector& dv,
-		    const fcn_handle_elt& val = resize_fill_value ())
-    : ArrayN<fcn_handle_elt> (dv, val) { }
-
-  fcn_handle_array (octave_function *f, const std::string& nm)
-    : ArrayN<fcn_handle_elt> (dim_vector (1, 1), fcn_handle_elt (f, nm)) { }
-
-  fcn_handle_array (const ArrayN<fcn_handle_elt>& fa)
-    : ArrayN<fcn_handle_elt> (fa) { }
-
-  fcn_handle_array (const fcn_handle_array& fa)
-    : ArrayN<fcn_handle_elt> (fa) { }
-
-  ~fcn_handle_array (void) { }
-
-  fcn_handle_array& operator = (const fcn_handle_array& fa)
-    {
-      if (this != &fa)
-	ArrayN<fcn_handle_elt>::operator = (fa);
-
-      return *this;
-    }
-
-  fcn_handle_array squeeze (void) const
-    { return ArrayN<fcn_handle_elt>::squeeze (); }
-
-  boolNDArray all (int dim = -1) const;
-  boolNDArray any (int dim = -1) const;
-
-  ArrayN<std::string> names (void) const;
-
-  static int compute_index (Array<int>& ra_idx,
-			    const dim_vector& dimensions);
-
-  static fcn_handle_elt resize_fill_value (void)
-    {
-      static fcn_handle_elt nil_handle = fcn_handle_elt ();
-      return nil_handle;
-    }
-};
-
-class
-octave_fcn_handle : public octave_base_matrix<fcn_handle_array>
-{
-public:
-
-  octave_fcn_handle (void)
-    : octave_base_matrix<fcn_handle_array> () { }
+  octave_fcn_handle (void) : fcn (0), nm () { }
 
   octave_fcn_handle (octave_function *f, const std::string& n)
-    : octave_base_matrix<fcn_handle_array>
-        (fcn_handle_array (dim_vector (1, 1), fcn_handle_elt (f, n))) { }
-
-  octave_fcn_handle (const fcn_handle_array& fha)
-    : octave_base_matrix<fcn_handle_array> (fha) { }
-
-  octave_fcn_handle (const octave_fcn_handle& fh)
-    : octave_base_matrix<fcn_handle_array> (fh) { }
+    : fcn (f), nm (n) { }
 
   ~octave_fcn_handle (void) { }
 
-  octave_value *clone (void) const { return new octave_fcn_handle (*this); }
-  octave_value *empty_clone (void) const { return new octave_fcn_handle (); }
-
   octave_value subsref (const std::string&,
 			const std::list<octave_value_list>&)
     {
@@ -159,35 +63,37 @@
 			     const std::list<octave_value_list>& idx,
 			     int nargout);
 
-  bool is_matrix_type (void) const { return false; }
-
-  bool is_numeric_type (void) const { return false; }
-
-  bool is_constant (void) const { return false; }
-
-  bool is_true (void) { return false; }
+  bool is_defined (void) const { return true; }
 
   bool is_function_handle (void) const { return true; }
 
-  octave_function *function_value (bool = false);
+  octave_function *function_value (bool = false) { return fcn; }
 
-  std::string name (void) const;
+  std::string name (void) const { return nm; }
 
   octave_fcn_handle *fcn_handle_value (bool = false) { return this; }
 
-  fcn_handle_array fcn_handle_array_value (void) const { return matrix; }
-
-  ArrayN<std::string> name_array (void) const { return matrix.names (); }
-
   void print (std::ostream& os, bool pr_as_read_syntax = false) const;
 
   void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const;
 
 private:
 
+  // No copying!
+
+  octave_fcn_handle (const octave_fcn_handle& fh);
+
+  octave_fcn_handle& operator = (const octave_fcn_handle& fh);
+
   DECLARE_OCTAVE_ALLOCATOR
 
   DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
+
+  // The function we are handling.
+  octave_function *fcn;
+
+  // The name of the handle, including the "@".
+  std::string nm;
 };
 
 extern octave_value make_fcn_handle (const std::string& nm);