114 template <
typename T>
125 return untyped == other.
untyped;
128 return untyped != other.
untyped;
131 return untyped < other.
untyped;
138 template <
typename T>
140 operator<<(std::ostream &ostr, const TypedId<T> &id)
145 return (ostr <<
"<none>");
147 return (ostr <<
"#" <<
id.untyped);
176 template <
typename T>
185 template <
typename Item,
typename Id>
203 static int add(std::shared_ptr<WithId>);
204 static void release(
int);
205 static std::shared_ptr<WithId>
get(int);
207 template <
typename Derived>
209 std::shared_ptr<WithId> p =
get(id);
210 return bool(std::dynamic_pointer_cast<Derived>(p));
213 template <
typename Derived>
214 static std::shared_ptr<Derived>
getAs(
int id) {
215 std::shared_ptr<WithId> p =
get(id);
216 return std::dynamic_pointer_cast<Derived>(p);
224 template <
typename Item,
typename Id>
228 static Id
add(std::shared_ptr<Item> item) {
237 static void release(std::shared_ptr<Item> item) {
238 release(item->getId());
241 template <
typename Derived>
243 return AnyById::isa<Derived>(
id.untyped);
246 template <
typename Derived>
247 static std::shared_ptr<Derived>
getAs(Id
id) {
248 return AnyById::getAs<Derived>(
id.untyped);
251 static std::shared_ptr<Item>
get(Id id) {
252 return getAs<Item>(id);
264 auto exportable = getAs<XmlExportable>(id);
266 return exportable->getExportId();
static void release(std::shared_ptr< Item > item)
static std::shared_ptr< Derived > getAs(Id id)
int getUntypedId() const
Return an id for this object.
static std::shared_ptr< Derived > getAs(int id)
Id getId() const
Return an id for this object.
static Id add(std::shared_ptr< Item > item)
static int add(std::shared_ptr< WithId >)
bool operator!=(const TypedId &other) const
bool operator<(const TypedId &other) const
bool operator==(const TypedId &other) const
static void release(Id id)
!! to do: review how often we are calling getAs<...> when we could
static int getExportId(Id id)
If the Item type is an XmlExportable, return the export ID of the given item ID.