summaryrefslogtreecommitdiff
path: root/cpp/src/Ice/SliceChecksums.cpp
blob: c29e2fbb41b2e02c01badd2776b7ddbc8746f2b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// **********************************************************************
//
// Copyright (c) 2003-2004 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************

#include <Ice/SliceChecksums.h>
#include <IceUtil/StaticMutex.h>

using namespace std;
using namespace Ice;

static SliceChecksumDict* _sliceChecksums = 0;
static IceUtil::StaticMutex _mutex = ICE_STATIC_MUTEX_INITIALIZER;

class SliceChecksumDictDestroyer
{
public:
    
    ~SliceChecksumDictDestroyer()
    {
	delete _sliceChecksums;
	_sliceChecksums = 0;
    }
};
static SliceChecksumDictDestroyer destroyer;

SliceChecksumDict
Ice::sliceChecksums()
{
    IceUtil::StaticMutex::Lock lock(_mutex);
    if(_sliceChecksums == 0)
    {
	_sliceChecksums = new SliceChecksumDict();
    }
    return *_sliceChecksums;
}

IceInternal::SliceChecksumInit::SliceChecksumInit(const char* checksums[])
{
    IceUtil::StaticMutex::Lock lock(_mutex);
    if(_sliceChecksums == 0)
    {
	_sliceChecksums = new SliceChecksumDict();
    }

    for(int i = 0; checksums[i] != 0; i += 2)
    {
        _sliceChecksums->insert(SliceChecksumDict::value_type(checksums[i], checksums[i + 1]));
    }
}