X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=ginac%2Fstructure.cpp;h=54dc1dfc62ae7f592eb50d362a6716a441e3ed38;hp=5082a284264a43a01e123e384da35925f9952b1c;hb=6cf1171daa84575b8799ac4fa5d2564456463bd5;hpb=15d4b353c85f8815a95d97ab977c9ca48e155574 diff --git a/ginac/structure.cpp b/ginac/structure.cpp index 5082a284..54dc1dfc 100644 --- a/ginac/structure.cpp +++ b/ginac/structure.cpp @@ -3,7 +3,7 @@ * Implementation of 'abstract' class structure. */ /* - * GiNaC Copyright (C) 1999-2000 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2001 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 @@ -23,160 +23,74 @@ #include #include "structure.h" +#include "archive.h" #include "debugmsg.h" +#include "utils.h" +#include "print.h" -#ifndef NO_GINAC_NAMESPACE namespace GiNaC { -#endif // ndef NO_GINAC_NAMESPACE + +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(0); -} - -structure::structure(structure const & other) -{ - debugmsg("structure copy constructor",LOGLEVEL_CONSTRUCT); - copy(other); -} - -structure const & structure::operator=(structure const & other) -{ - debugmsg("structure operator=",LOGLEVEL_ASSIGNMENT); - if (this != &other) { - destroy(1); - copy(other); - } - return *this; -} - -// protected - -void structure::copy(structure const & 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 bases classes ////////// -// public - -basic * structure::duplicate() const +void structure::print(const print_context & c, unsigned level) const { - debugmsg("structure duplicate",LOGLEVEL_DUPLICATE); - return new structure(*this); -} + debugmsg("structure print",LOGLEVEL_PRINT); -void structure::printraw(ostream & os) const -{ - debugmsg("structure printraw",LOGLEVEL_PRINT); + if (is_of_type(c, print_tree)) { - os << "structure(hash=" << hashvalue << ",flags=" << flags << ")"; -} - -void structure::print(ostream & os, unsigned upper_precedence) const -{ - debugmsg("structure print",LOGLEVEL_PRINT); - - os << "structure()"; -} - -void structure::printtree(ostream & os, unsigned indent) const -{ - debugmsg("structure printtree",LOGLEVEL_PRINT); + c.s << std::string(level, ' ') << class_name() + << std::hex << ", hash=0x" << hashvalue << ", flags=0x" << flags << std::dec + << std::endl; - os << string(indent,' ') << "structure " - << "hash=" << hashvalue << " (0x" << hex << hashvalue << dec << ")" - << ", flags=" << flags << endl; -} - -void structure::printcsrc(ostream & os, unsigned type, unsigned upper_precedence) const -{ - debugmsg("structure print csrc",LOGLEVEL_PRINT); - - os << "structure()"; + } else + c.s << class_name() << "()"; } // protected -int structure::compare_same_type(basic const & 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(basic const & other) const +bool structure::is_equal_same_type(const basic & other) const { - GINAC_ASSERT(is_of_type(other, structure)); - return true; // all structures are the same + GINAC_ASSERT(is_of_type(other, structure)); + return true; // all structures are the same } ////////// -// new virtual structures which can be overridden by derived classes -////////// - -// none - -////////// -// non-virtual structures in this class +// non-virtual functions in this class ////////// // protected -vector & structure::registered_structures(void) +std::vector & structure::registered_structures(void) { - static vector * rs=new vector; - return *rs; + static std::vector * rs = new std::vector; + return *rs; } // public -unsigned structure::register_new(char const * nm) +unsigned structure::register_new(const char * nm) { - registered_structure_info rsi={nm}; - registered_structures().push_back(rsi); - return registered_structures().size()-1; + registered_structure_info rsi={nm}; + registered_structures().push_back(rsi); + return registered_structures().size()-1; } -////////// -// static member variables -////////// - -// none - -////////// -// global constants -////////// - -const structure some_structure; -type_info const & typeid_structure=typeid(some_structure); - -#ifndef NO_GINAC_NAMESPACE } // namespace GiNaC -#endif // ndef NO_GINAC_NAMESPACE