source: trunk/src/uid.cc @ 149

Last change on this file since 149 was 59, checked in by epyon, 12 years ago
  • rudimentary uid_store added
File size: 839 bytes
Line 
1// Copyright (C) 2012-2013 ChaosForge / Kornel Kisielewicz
2// http://chaosforge.org/
3//
4// This file is part of NV Libraries.
5// For conditions of distribution and use, see copyright notice in nv.hh
6
7#include "nv/uid.hh"
8
9using namespace nv;
10
11uid_store::uid_store()
12        : m_map(), m_current(0)
13{
14       
15}
16
17object* uid_store::get( uid auid ) const
18{
19        map::const_iterator i = m_map.find( auid );
20        if ( i != m_map.end() )
21        {
22                return i->second;
23        }
24        return nullptr;
25}
26
27bool uid_store::remove( uid auid )
28{
29        return m_map.erase( auid ) != 0;
30}
31
32void uid_store::insert( object* o, uid auid )
33{
34        m_map[ auid ] = o;
35}
36
37uid uid_store::insert( object* o )
38{
39        uid u = request_uid();
40        m_map[ u ] = o;
41        return u;
42}
43
44uid uid_store::request_uid()
45{
46        return ++m_current;
47}
48
49uid_store::~uid_store()
50{
51        // no-op
52}
Note: See TracBrowser for help on using the repository browser.