Update README.md
[nemesis.git] / Platform / SerializerFactory.cpp
1 /*
2  Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved.
3
4  Governed by the TrueCrypt License 3.0 the full text of which is contained in
5  the file License.txt included in TrueCrypt binary and source code distribution
6  packages.
7 */
8
9 #include <stdexcept>
10 #include "SerializerFactory.h"
11
12 namespace TrueCrypt
13 {
14         void SerializerFactory::Deinitialize ()
15         {
16                 if (--UseCount == 0)
17                 {
18                         delete NameToTypeMap;
19                         delete TypeToNameMap;
20                 }
21         }
22
23         string SerializerFactory::GetName (const type_info &typeInfo)
24         {
25                 string typeName = StringConverter::GetTypeName (typeInfo);
26                 if (TypeToNameMap->find (typeName) == TypeToNameMap->end())
27                         throw std::runtime_error (SRC_POS);
28
29                 return (*TypeToNameMap)[typeName];
30         }
31
32         Serializable *SerializerFactory::GetNewSerializable (const string &typeName)
33         {
34                 if (NameToTypeMap->find (typeName) == NameToTypeMap->end())
35                         throw std::runtime_error (SRC_POS);
36
37                 return (*NameToTypeMap)[typeName].GetNewPtr();
38         }
39
40         void SerializerFactory::Initialize ()
41         {
42                 if (UseCount == 0)
43                 {
44                         NameToTypeMap = new map <string, SerializerFactory::MapEntry>;
45                         TypeToNameMap = new map <string, string>;
46                 }
47
48                 ++UseCount;
49         }
50
51         map <string, SerializerFactory::MapEntry> *SerializerFactory::NameToTypeMap;
52         map <string, string> *SerializerFactory::TypeToNameMap;
53         int SerializerFactory::UseCount;
54 }
This page took 0.026329 seconds and 3 git commands to generate. Download a nemesis OSX (sierra+high sierra, tested/working) binary, with fuse-ext3 via e2fsprogs, at this link. application and installer are signed by screwjack, llc. must install fuse with macFUSE layer first.