|
| 1 | +/* |
| 2 | + * Copyright (c) 2022, Matt Hall |
| 3 | + * |
| 4 | + * Redistribution and use in source and binary forms, with or without |
| 5 | + * modification, are permitted provided that the following conditions are met: |
| 6 | + * |
| 7 | + * 1. Redistributions of source code must retain the above copyright notice, |
| 8 | + * this list of conditions and the following disclaimer. |
| 9 | + * |
| 10 | + * 2. Redistributions in binary form must reproduce the above copyright notice, |
| 11 | + * this list of conditions and the following disclaimer in the documentation |
| 12 | + * and/or other materials provided with the distribution. |
| 13 | + * |
| 14 | + * 3. Neither the name of the copyright holder nor the names of its |
| 15 | + * contributors may be used to endorse or promote products derived from |
| 16 | + * this software without specific prior written permission. |
| 17 | + * |
| 18 | + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 19 | + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 20 | + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 21 | + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
| 22 | + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 23 | + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 24 | + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 25 | + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 26 | + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 27 | + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 28 | + * POSSIBILITY OF SUCH DAMAGE. |
| 29 | + */ |
| 30 | + |
| 31 | +/** @file Instance.hpp |
| 32 | + * Base class for the moordyn::Body, moordyn::Line, moordyn::Point and |
| 33 | + * moordyn::Rod objects. |
| 34 | + */ |
| 35 | + |
| 36 | +#pragma once |
| 37 | + |
| 38 | +#include "IO.hpp" |
| 39 | +#include "Log.hpp" |
| 40 | +#include <utility> |
| 41 | + |
| 42 | +namespace moordyn { |
| 43 | + |
| 44 | +class Waves; |
| 45 | +typedef std::shared_ptr<Waves> WavesRef; |
| 46 | + |
| 47 | +class Point; |
| 48 | +class Rod; |
| 49 | + |
| 50 | +/** @class Instance Instance.hpp |
| 51 | + * @brief A generic instance |
| 52 | + */ |
| 53 | +class DECLDIR Instance : public io::IO |
| 54 | +{ |
| 55 | + public: |
| 56 | + /** @brief Costructor |
| 57 | + * @param log Logging handler defining where/how results should be logged. |
| 58 | + */ |
| 59 | + Instance(moordyn::Log* log); |
| 60 | + |
| 61 | + /** @brief Destructor |
| 62 | + */ |
| 63 | + virtual ~Instance() = default; |
| 64 | + |
| 65 | + /** @brief Get the unique identifier of this instance |
| 66 | + * |
| 67 | + * The unique identifier is a growing index which identifies every single |
| 68 | + * created instance. Even if an instance is removed, the index will remain |
| 69 | + * taken. |
| 70 | + * @return The unique identifier |
| 71 | + */ |
| 72 | + inline const size_t Id() const { return _id; } |
| 73 | + |
| 74 | + /** @brief Get the number of state variables required by this instance |
| 75 | + * |
| 76 | + * This can be seen as the number of rows on the state variables holder. |
| 77 | + * @return The number of state variables |
| 78 | + */ |
| 79 | + virtual inline const size_t state_n() const { return 1; } |
| 80 | + |
| 81 | + /** @brief Get the dimension of the state variable. |
| 82 | + * |
| 83 | + * This can be seen as the number of columns on the state variables holder. |
| 84 | + * @return The dimension of the state variable |
| 85 | + */ |
| 86 | + virtual inline const size_t state_dims() const { return 6; } |
| 87 | + private: |
| 88 | + /// Unique identifier of this instance |
| 89 | + size_t _id; |
| 90 | +}; |
| 91 | + |
| 92 | +} // ::moordyn |
0 commit comments