]> www.ginac.de Git - ginac.git/blobdiff - ginac/ex.h
#ifndef around namespace GiNaC { }
[ginac.git] / ginac / ex.h
index 2300627e10869e594daac31fbea46864f1a4a82a..29b9b077f0f82a45c0b1fe6c470e5c2b85ea8f30 100644 (file)
@@ -2,23 +2,43 @@
  *
  *  Interface to GiNaC's light-weight expression handles. */
 
-#ifndef _EX_H_
-#define _EX_H_
+/*
+ *  GiNaC Copyright (C) 1999 Johannes Gutenberg University Mainz, Germany
+ *
+ *  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
+ */
+
+#ifndef __GINAC_EX_H__
+#define __GINAC_EX_H__
 
 #include <iostream>
+#include <ginac/basic.h>
+#include <ginac/operators.h>
+
+#ifndef NO_GINAC_NAMESPACE
+namespace GiNaC {
+#endif // ndef NO_GINAC_NAMESPACE
 
 class ex;
 class expand_options;
 class status_flags;
 
-#include "basic.h"
-#include "debugmsg.h"
-#include "flags.h"
-
 class symbol;
 class lst;
 
-typedef vector<ex> exvector;
+// typedef vector<ex> exvector;
 
 // enum definitions
 
@@ -47,10 +67,9 @@ public:
 #ifdef INLINE_EX_CONSTRUCTORS
     : bp(exZERO().bp)
         {
-            debugmsg("ex default constructor",LOGLEVEL_CONSTRUCT);
-            ASSERT(exZERO().bp!=0);
-            ASSERT(exZERO().bp->flags & status_flags::dynallocated);
-            ASSERT(bp!=0);
+            GINAC_ASSERT(exZERO().bp!=0);
+            GINAC_ASSERT(exZERO().bp->flags & status_flags::dynallocated);
+            GINAC_ASSERT(bp!=0);
             ++bp->refcount;
         }
 #else
@@ -60,9 +79,8 @@ public:
     ~ex()
 #ifdef INLINE_EX_CONSTRUCTORS
         {
-            debugmsg("ex destructor",LOGLEVEL_DESTRUCT);
-            ASSERT(bp!=0);
-            ASSERT(bp->flags & status_flags::dynallocated);
+            GINAC_ASSERT(bp!=0);
+            GINAC_ASSERT(bp->flags & status_flags::dynallocated);
             if (--bp->refcount == 0) {
                 delete bp;
             }
@@ -75,9 +93,8 @@ public:
 #ifdef INLINE_EX_CONSTRUCTORS
     : bp(other.bp)
         {
-            debugmsg("ex copy constructor",LOGLEVEL_CONSTRUCT);
-            ASSERT(bp!=0);
-            ASSERT((bp->flags) & status_flags::dynallocated);
+            GINAC_ASSERT(bp!=0);
+            GINAC_ASSERT((bp->flags) & status_flags::dynallocated);
             ++bp->refcount;
         }
 #else
@@ -87,11 +104,10 @@ public:
     ex const & operator=(ex const & other)
 #ifdef INLINE_EX_CONSTRUCTORS
         {
-            debugmsg("ex operator=",LOGLEVEL_ASSIGNMENT);
-            ASSERT(bp!=0);
-            ASSERT(bp->flags & status_flags::dynallocated);
-            ASSERT(other.bp!=0);
-            ASSERT(other.bp->flags & status_flags::dynallocated);
+            GINAC_ASSERT(bp!=0);
+            GINAC_ASSERT(bp->flags & status_flags::dynallocated);
+            GINAC_ASSERT(other.bp!=0);
+            GINAC_ASSERT(other.bp->flags & status_flags::dynallocated);
             ++other.bp->refcount;
             basic * tmpbp=other.bp;
             if (--bp->refcount==0) {
@@ -109,7 +125,6 @@ public:
     ex(basic const & other)
 #ifdef INLINE_EX_CONSTRUCTORS
     {
-        debugmsg("ex constructor from basic",LOGLEVEL_CONSTRUCT);
         construct_from_basic(other);
     }
 #else
@@ -172,8 +187,8 @@ public:
     int compare(ex const & other) const
 #ifdef INLINE_EX_CONSTRUCTORS
         {
-            ASSERT(bp!=0);
-            ASSERT(other.bp!=0);
+            GINAC_ASSERT(bp!=0);
+            GINAC_ASSERT(other.bp!=0);
             if (bp==other.bp) {
                 // special case: both expression point to same basic, trivially equal
                 return 0; 
@@ -186,8 +201,8 @@ public:
     bool is_equal(ex const & other) const
 #ifdef INLINE_EX_CONSTRUCTORS
         {
-            ASSERT(bp!=0);
-            ASSERT(other.bp!=0);
+            GINAC_ASSERT(bp!=0);
+            GINAC_ASSERT(other.bp!=0);
             if (bp==other.bp) {
                 // special case: both expression point to same basic, trivially equal
                 return true; 
@@ -214,9 +229,14 @@ private:
 
 public:
     basic *bp;
-
 };
 
+// utility functions
+inline bool are_ex_trivially_equal(const ex &e1, const ex &e2)
+{
+       return e1.bp == e2.bp;
+}
+
 // wrapper functions around member functions
 inline int nops(ex const & thisex)
 { return thisex.nops(); }
@@ -266,4 +286,9 @@ inline ex subs(ex const & thisex, lst const & ls, lst const & lr)
 inline void swap(ex & e1, ex & e2)
 { e1.swap(e2); }
 
-#endif // ndef _EX_H_
+#ifndef NO_GINAC_NAMESPACE
+} // namespace GiNaC
+#endif // ndef NO_GINAC_NAMESPACE
+
+#endif // ndef __GINAC_EX_H__
+