source: git/Singular/PolyWrapper.cc @ f2dcd1

spielwiese
Last change on this file since f2dcd1 was f2dcd1, checked in by Frank Seelisch <seelisch@…>, 15 years ago
more stuff for C++ wrapper implementation git-svn-id: file:///usr/local/Singular/svn/trunk@12152 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 2.7 KB
Line 
1#include "mod2.h"
2
3#ifdef HAVE_WRAPPERS
4
5#include "PolyWrapper.h"
6#include "CanonicalPoly.h"
7#include "Wrappers.h"
8#include <iostream>
9#include "febase.h"
10
11PolyWrapper PolyWrapper::operator+ (const PolyWrapper& p) const
12{
13  +prpr > "PolyWrapper::operator+ called";
14  prpr+1;
15  +prpr > "first argument = " < this->toString();
16  +prpr > "second argument = " < p.toString();
17  prpr-1;
18  PolyWrapper q(this->getInternPoly()->deepCopy());  // deep copy of given PolyWrapper
19  q.getInternPoly()->add(p.getInternPoly());
20  return q;
21}
22
23PolyWrapper& PolyWrapper::operator+= (const PolyWrapper& p)
24{
25  +prpr > "PolyWrapper::operator+= called";
26  prpr+1;
27  +prpr > "first argument = " < this->toString();
28  +prpr > "second argument = " < p.toString();
29  prpr-1;
30  if (this->getInternPoly()->isShared())
31  {
32    m_pInternPoly->decrement();
33    m_pInternPoly = m_pInternPoly->deepCopy();
34  }
35  this->getInternPoly()->add(p.getInternPoly());
36  return *this;
37}
38
39const RingWrapper& PolyWrapper::getRing () const
40{
41  return m_pInternPoly->getRing();
42}
43
44PolyWrapper::PolyWrapper (): m_pInternPoly(0)
45{
46  assume(false); // the default constructor, i.e. the one
47                 // without arguments should never be called
48}
49
50PolyWrapper::PolyWrapper (InternPoly* ip): m_pInternPoly(ip)
51{
52  +prpr > "PolyWrapper constructor with argument InternPoly*";
53}
54
55PolyWrapper::~PolyWrapper ()
56{
57  +prpr > "PolyWrapper destructor, object = " < this->toString();
58  InternPoly* p_ip = this->getInternPoly();
59  p_ip->decrement();
60  if (p_ip->getCounter() == 0) delete p_ip;
61}
62
63PolyWrapper::PolyWrapper (const PolyWrapper& p)
64{
65  +prpr > "creating a shallow copy of PolyWrapper, argument = " < p.toString();
66  m_pInternPoly = p.getInternPoly();
67  m_pInternPoly->increment();
68}
69
70PolyWrapper& PolyWrapper::operator= (const PolyWrapper& p)
71{
72  +prpr > "assignment operator of PolyWrapper, argument = " < p.toString();
73  prpr+1;
74  +prpr > "working with PolyWrapper " < this->toString();
75  prpr+1;
76  m_pInternPoly->decrement();
77  if (m_pInternPoly->getCounter() == 0) delete m_pInternPoly;
78  m_pInternPoly = p.getInternPoly();
79  prpr-1;
80  +prpr > "working with PolyWrapper " < this->toString();
81  prpr+1;
82  m_pInternPoly->increment();
83  prpr-2;
84  +prpr > "assignment of PolyWrapper completed";
85  return *this;
86}
87
88void PolyWrapper::print () const
89{
90  PrintS(this->toString());
91}
92
93void PolyWrapper::printLn () const
94{
95  PrintS(this->toString());
96  PrintLn();
97}
98
99char* PolyWrapper::toString () const
100{
101  InternPoly* pip = this->getInternPoly();
102  return pip->toString();
103}
104
105InternPoly* PolyWrapper::getInternPoly () const
106{
107  return m_pInternPoly;
108}
109
110PolyWrapper::PolyWrapper (const int i, const RingWrapper& r) {
111  +prpr > "creating a new PolyWrapper (internal type: CanonicalPoly)";
112  m_pInternPoly = new CanonicalPoly(i, r);
113}
114
115#endif // HAVE_WRAPPERS
Note: See TracBrowser for help on using the repository browser.