X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?a=blobdiff_plain;f=ginac%2Fstructure.cpp;h=e1ea6d56577349461171b03969942affcb68c5cd;hb=c0a4c8517ff840df981a1ba3d3773774268f7e79;hp=ddd953dffc5424c28aabe0b0e70d014404db10e6;hpb=e58227e1112f989f3b5417e497a61d53fc2971fa;p=ginac.git diff --git a/ginac/structure.cpp b/ginac/structure.cpp index ddd953df..e1ea6d56 100644 --- a/ginac/structure.cpp +++ b/ginac/structure.cpp @@ -23,114 +23,48 @@ #include #include "structure.h" +#include "archive.h" #include "debugmsg.h" +#include "utils.h" +#include "print.h" -#ifndef NO_NAMESPACE_GINAC namespace GiNaC { -#endif // ndef NO_NAMESPACE_GINAC + +GINAC_IMPLEMENT_REGISTERED_CLASS(structure, basic) ////////// -// default constructor, destructor, copy constructor assignment operator and helpers +// default ctor, dtor, copy ctor assignment operator and helpers ////////// -// public - -structure::structure() -{ - debugmsg("structure default constructor",LOGLEVEL_CONSTRUCT); - tinfo_key = TINFO_structure; -} - -structure::~structure() -{ - debugmsg("structure destructor",LOGLEVEL_DESTRUCT); - destroy(false); -} - -structure::structure(const structure & other) -{ - debugmsg("structure copy constructor",LOGLEVEL_CONSTRUCT); - copy(other); -} - -const structure & structure::operator=(const structure & other) -{ - debugmsg("structure operator=",LOGLEVEL_ASSIGNMENT); - if (this != &other) { - destroy(true); - copy(other); - } - return *this; -} - -// protected - -void structure::copy(const structure & other) -{ - basic::copy(other); -} - -void structure::destroy(bool call_parent) -{ - if (call_parent) basic::destroy(call_parent); -} +DEFAULT_CTORS(structure) ////////// -// other constructors +// archiving ////////// -// none +DEFAULT_ARCHIVING(structure) ////////// -// structures overriding virtual structures from bases classes +// functions overriding virtual functions from base classes ////////// -// public - -basic * structure::duplicate() const -{ - debugmsg("structure duplicate",LOGLEVEL_DUPLICATE); - return new structure(*this); -} - -void structure::printraw(std::ostream & os) const -{ - debugmsg("structure printraw",LOGLEVEL_PRINT); - - os << "structure(hash=" << hashvalue << ",flags=" << flags << ")"; -} - -void structure::print(std::ostream & os, unsigned upper_precedence) const +void structure::print(const print_context & c, unsigned level) const { debugmsg("structure print",LOGLEVEL_PRINT); - os << "structure()"; -} - -void structure::printtree(std::ostream & os, unsigned indent) const -{ - debugmsg("structure printtree",LOGLEVEL_PRINT); - - os << std::string(indent,' ') << "structure " - << "hash=" << hashvalue - << " (0x" << std::hex << hashvalue << std::dec << ")" - << ", flags=" << flags << std::endl; -} + if (is_of_type(c, print_tree)) { -void structure::printcsrc(std::ostream & os, unsigned type, unsigned upper_precedence) const -{ - debugmsg("structure print csrc",LOGLEVEL_PRINT); + c.s << std::string(level, ' ') << class_name() + << std::hex << ", hash=0x" << hashvalue << ", flags=0x" << flags << std::dec + << std::endl; - os << "structure()"; + } else + c.s << class_name() << "()"; } // protected -int structure::compare_same_type(const basic & other) const -{ - GINAC_ASSERT(is_of_type(other, structure)); - return 0; // all structures are the same -} +DEFAULT_COMPARE(structure) bool structure::is_equal_same_type(const basic & other) const { @@ -139,13 +73,7 @@ bool structure::is_equal_same_type(const basic & other) const } ////////// -// new virtual structures which can be overridden by derived classes -////////// - -// none - -////////// -// non-virtual structures in this class +// non-virtual functions in this class ////////// // protected @@ -165,6 +93,4 @@ unsigned structure::register_new(const char * nm) return registered_structures().size()-1; } -#ifndef NO_NAMESPACE_GINAC } // namespace GiNaC -#endif // ndef NO_NAMESPACE_GINAC