/* This file is part of Lemma, a geophysical modelling and inversion API. * More information is available at http://lemmasoftware.org */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ /** * @file * @date 05/31/2016 12:27:31 PM * @version $Id$ * @author Trevor Irons (ti) * @email tirons@egi.utah.edu * @copyright Copyright (c) 2016, University of Utah * @copyright Copyright (c) 2016, Lemma Software, LLC */ #include "DEMParticle.h" namespace Lemma { // ==================== FRIEND METHODS ===================== #ifdef HAVE_YAMLCPP std::ostream &operator << (std::ostream &stream, const DEMParticle &ob) { stream << ob.Serialize() << "\n---\n"; // End of doc --- as a direct stream should encapulste thingy return stream; } #else std::ostream &operator<<(std::ostream &stream, const DEMParticle& ob) { stream << *(LemmaObject*)(&ob); return stream; } #endif // ==================== LIFECYCLE ======================= //-------------------------------------------------------------------------------------- // Class: DEMParticle // Method: DEMParticle // Description: constructor (protected) //-------------------------------------------------------------------------------------- DEMParticle::DEMParticle (const std::string& name) : LemmaObject(name) { } // ----- end of method DEMParticle::DEMParticle (constructor) ----- #ifdef HAVE_YAMLCPP //-------------------------------------------------------------------------------------- // Class: DEMParticle // Method: DEMParticle // Description: DeSerializing constructor (protected) //-------------------------------------------------------------------------------------- DEMParticle::DEMParticle (const YAML::Node& node) : LemmaObject(node) { this->centreMass = node["centreMass"].as(); } // ----- end of method DEMParticle::DEMParticle (constructor) ----- #endif //-------------------------------------------------------------------------------------- // Class: DEMParticle // Method: NewSP() // Description: public constructor //-------------------------------------------------------------------------------------- std::shared_ptr< DEMParticle > DEMParticle::NewSP() { std::shared_ptr sp(new DEMParticle("DEMParticle"), LemmaObjectDeleter() ); return sp; } //-------------------------------------------------------------------------------------- // Class: DEMParticle // Method: ~DEMParticle // Description: destructor (protected) //-------------------------------------------------------------------------------------- DEMParticle::~DEMParticle () { } // ----- end of method DEMParticle::~DEMParticle (destructor) ----- #ifdef HAVE_YAMLCPP //-------------------------------------------------------------------------------------- // Class: DEMParticle // Method: Serialize //-------------------------------------------------------------------------------------- YAML::Node DEMParticle::Serialize ( ) const { YAML::Node node = LemmaObject::Serialize();; node.SetTag( this->GetName() ); // FILL IN CLASS SPECIFICS HERE node["centreMass"] = centreMass; return node; } // ----- end of method DEMParticle::Serialize ----- //-------------------------------------------------------------------------------------- // Class: DEMParticle // Method: DeSerialize //-------------------------------------------------------------------------------------- std::shared_ptr DEMParticle::DeSerialize ( const YAML::Node& node ) { std::shared_ptr Object(new DEMParticle(node), LemmaObjectDeleter() ); DESERIALIZECHECK( node, Object.get() ) return Object ; } // ----- end of method DEMParticle::DeSerialize ----- #endif //-------------------------------------------------------------------------------------- // Class: DEMParticle // Method: GetCentreMass //-------------------------------------------------------------------------------------- Vector3r DEMParticle::GetCentreMass ( ) { return centreMass; } // ----- end of method DEMParticle::get_CentreMass ----- //-------------------------------------------------------------------------------------- // Class: DEMParticle // Method: SetCentreMass //-------------------------------------------------------------------------------------- void DEMParticle::SetCentreMass ( const Vector3r& pos ) { centreMass = pos; return ; } // ----- end of method DEMParticle::set_CentreMass ----- } // ----- end of Lemma name -----