summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/tests/Concurrency/CC_test_utils.cpp
blob: 4080b9e369f753967530c34f5154b327f3fccff9 (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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// $Id$

// ============================================================================
//
// = LIBRARY
//    TAO/orbsvcs/tests
//
// = FILENAME
//    CC_test_utils.cpp
//
// = DESCRIPTION
//      This class provides a namespace for utility functions for the
//      concurrency service test.
//
// = AUTHORS
//      Torben Worm <tworm@cs.wustl.edu>
//
// ============================================================================

#include "CC_test_utils.h"
#include "CC_naming_service.h"
#include "ace/OS.h"
#include "ace/Log_Msg.h"

ACE_RCSID(Concurrency, CC_test_utils, "$Id$")

char *CC_TestUtils::get_lock_mode_name (CosConcurrencyControl::lock_mode mode)
{
  if (mode==CosConcurrencyControl::read)
    return const_cast<char*> ("read");

  if (mode==CosConcurrencyControl::write)
    return  const_cast<char*> ("write");

  if (mode==CosConcurrencyControl::upgrade)
    return const_cast<char*> ("upgrade");

  if (mode==CosConcurrencyControl::intention_read)
    return const_cast<char*> ("intention_read");

  if (mode==CosConcurrencyControl::intention_write)
    return const_cast<char*> ("intention_write");

  return const_cast<char*> ("unknown lock mode");
}

CosConcurrencyControl::LockSet_ptr
CC_TestUtils::create_lock_set (void)
{
  // Create the lock set and return an obj ref corresponding to the
  // key.
  CosConcurrencyControl::LockSet_ptr lock_set(0);
  try
    {
      lock_set =
        CC_naming_service::Instance()->get_lock_set_factory ()->create ();

      if (CORBA::is_nil (lock_set))
        ACE_ERROR_RETURN ((LM_ERROR,
                           "null lock set objref returned by factory\n"),
                          0);
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("CC_Client::create_lock_set");
      return 0;
    }
  return lock_set;
}