Neale Ranns | 812ed39 | 2017-10-16 04:20:13 -0700 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (c) 2017 Cisco and/or its affiliates. |
| 3 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | * you may not use this file except in compliance with the License. |
| 5 | * You may obtain a copy of the License at: |
| 6 | * |
| 7 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | * |
| 9 | * Unless required by applicable law or agreed to in writing, software |
| 10 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | * See the License for the specific language governing permissions and |
| 13 | * limitations under the License. |
| 14 | */ |
| 15 | |
| 16 | #include "vom/object_base.hpp" |
| 17 | |
| 18 | namespace VOM { |
| 19 | object_ref::object_ref(std::shared_ptr<object_base> obj) |
| 20 | : m_obj(obj) |
| 21 | , m_state(OBJECT_STATE_NONE) |
| 22 | { |
| 23 | } |
| 24 | |
| 25 | bool |
| 26 | object_ref::operator<(const object_ref& other) const |
| 27 | { |
| 28 | return (m_obj.get() < other.m_obj.get()); |
| 29 | } |
| 30 | |
| 31 | std::shared_ptr<object_base> |
| 32 | object_ref::obj() const |
| 33 | { |
| 34 | return (m_obj); |
| 35 | } |
| 36 | |
| 37 | void |
| 38 | object_ref::mark() const |
| 39 | { |
| 40 | m_state = OBJECT_STATE_STALE; |
| 41 | } |
| 42 | |
| 43 | void |
| 44 | object_ref::clear() const |
| 45 | { |
| 46 | m_state = OBJECT_STATE_NONE; |
| 47 | } |
| 48 | |
| 49 | bool |
| 50 | object_ref::stale() const |
| 51 | { |
| 52 | return (m_state == OBJECT_STATE_STALE); |
| 53 | } |
| 54 | |
| 55 | std::ostream& |
| 56 | operator<<(std::ostream& os, const object_base& o) |
| 57 | { |
| 58 | os << o.to_string(); |
| 59 | |
| 60 | return (os); |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | /* |
| 65 | * fd.io coding-style-patch-verification: ON |
| 66 | * |
| 67 | * Local Variables: |
| 68 | * eval: (c-set-style "mozilla") |
| 69 | * End: |
| 70 | */ |