X-Git-Url: https://ginac.de/ginac.git//ginac.git?a=blobdiff_plain;f=ginac%2Fstructure.cpp;h=e9c3b0213f45cb9055cbd2f3404604b4325328b7;hb=c20f44225542fd9e4c0cda17660af6a276d3ed9f;hp=b155f946629988c48c92e79c170f62adc0431a1c;hpb=a8507b8af1c08d9b27d98d57f95c7ca1a8671e27;p=ginac.git diff --git a/ginac/structure.cpp b/ginac/structure.cpp index b155f946..e9c3b021 100644 --- a/ginac/structure.cpp +++ b/ginac/structure.cpp @@ -1,8 +1,9 @@ /** @file structure.cpp * - * Implementation of 'abstract' class structure. - * - * GiNaC Copyright (C) 1999 Johannes Gutenberg University Mainz, Germany + * Implementation of 'abstract' class structure. */ + +/* + * 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 @@ -21,114 +22,115 @@ #include -#include "ginac.h" +#include "structure.h" +#include "archive.h" +#include "debugmsg.h" + +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(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; + debugmsg("structure default ctor",LOGLEVEL_CONSTRUCT); + tinfo_key = TINFO_structure; } // protected -void structure::copy(structure const & other) +void structure::copy(const structure & other) { - basic::copy(other); + basic::copy(other); } void structure::destroy(bool call_parent) { - if (call_parent) basic::destroy(call_parent); + if (call_parent) basic::destroy(call_parent); } ////////// -// other constructors +// other ctors ////////// // none ////////// -// structures overriding virtual structures from bases classes +// archiving ////////// -// public +/** Construct object from archive_node. */ +structure::structure(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst) +{ + debugmsg("structure ctor from archive_node", LOGLEVEL_CONSTRUCT); +} -basic * structure::duplicate() const +/** Unarchive the object. */ +ex structure::unarchive(const archive_node &n, const lst &sym_lst) { - debugmsg("structure duplicate",LOGLEVEL_DUPLICATE); - return new structure(*this); + return (new structure(n, sym_lst))->setflag(status_flags::dynallocated); } -void structure::printraw(ostream & os) const +/** Archive the object. */ +void structure::archive(archive_node &n) const { - debugmsg("structure printraw",LOGLEVEL_PRINT); + inherited::archive(n); +} - os << "structure(hash=" << hashvalue << ",flags=" << flags << ")"; +////////// +// structures overriding virtual structures from bases classes +////////// + +// public + +void structure::printraw(std::ostream & os) const +{ + debugmsg("structure printraw",LOGLEVEL_PRINT); + + os << class_name() << "(hash=" << hashvalue << ",flags=" << flags << ")"; } -void structure::print(ostream & os, unsigned upper_precedence) const +void structure::print(std::ostream & os, unsigned upper_precedence) const { - debugmsg("structure print",LOGLEVEL_PRINT); + debugmsg("structure print",LOGLEVEL_PRINT); - os << "structure()"; + os << class_name() << "()"; } -void structure::printtree(ostream & os, unsigned indent) const +void structure::printtree(std::ostream & os, unsigned indent) const { - debugmsg("structure printtree",LOGLEVEL_PRINT); + debugmsg("structure printtree",LOGLEVEL_PRINT); - os << string(indent,' ') << "structure " - << "hash=" << hashvalue << " (0x" << hex << hashvalue << dec << ")" - << ", flags=" << flags << endl; + os << std::string(indent,' ') << "structure " + << "hash=" << hashvalue + << " (0x" << std::hex << hashvalue << std::dec << ")" + << ", flags=" << flags << std::endl; } -void structure::printcsrc(ostream & os, unsigned type, unsigned upper_precedence) const +void structure::printcsrc(std::ostream & os, unsigned type, unsigned upper_precedence) const { - debugmsg("structure print csrc",LOGLEVEL_PRINT); + debugmsg("structure print csrc",LOGLEVEL_PRINT); - os << "structure()"; + os << "structure()"; } // protected -int structure::compare_same_type(basic const & other) const +int structure::compare_same_type(const basic & other) const { - ASSERT(is_of_type(other, structure)); - return 0; // all structures are the same + GINAC_ASSERT(is_of_type(other, structure)); + return 0; // all structures are the same } -bool structure::is_equal_same_type(basic const & other) const +bool structure::is_equal_same_type(const basic & other) const { - 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 } ////////// @@ -143,31 +145,19 @@ bool structure::is_equal_same_type(basic const & other) const // 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); - +} // namespace GiNaC