summaryrefslogtreecommitdiff
path: root/CIAO/DAnCE/TargetManager/ResourceCommitmentManager.cpp
blob: dbef7942d93aee78988127b0c1a9397ffff4eb6a (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
// $Id$
//
#include "ResourceCommitmentManager.h"
#include "DomainDataManager.h"
#include "DAnCE/Logger/Log_Macros.h"

DAnCE::ResourceCommitmentManager_i::ResourceCommitmentManager_i (void)
{
  DANCE_TRACE ("DAnCE::ResourceCommitmentManager_i");
}

DAnCE::ResourceCommitmentManager_i::~ResourceCommitmentManager_i (void)
{
  DANCE_TRACE ("DAnCE::~ResourceCommitmentManager_i");
}

void
DAnCE::ResourceCommitmentManager_i::commitResources (
    const ::Deployment::ResourceAllocations& resources)
{
  DANCE_TRACE ("DAnCE::ResourceCommitmentManager_i::commitResources");

  DOMAIN_DATA_MANAGER->commitResourceAllocation (resources);

  // Commit succesful .. add to commited resource, we get an exception
  // if the method above fails
  this->add_to_committed_resource (resources);
}

void
DAnCE::ResourceCommitmentManager_i::releaseResources (
    const ::Deployment::ResourceAllocations & resources)
{
  DANCE_TRACE ("DAnCE::ResourceCommitmentManager_i::releaseResources");

  // If the resources set is null, use the already allocated resources ..
  if (resources.length () == 0)
    {
      DOMAIN_DATA_MANAGER->releaseResourceAllocation (this->resources_);
    }
  else
    {
      DOMAIN_DATA_MANAGER->releaseResourceAllocation (resources);
    }
}

void
DAnCE::ResourceCommitmentManager_i::add_to_committed_resource (
    ::Deployment::ResourceAllocations res)
{
  DANCE_TRACE ("DAnCE::ResourceCommitmentManager_i::add_to_commited_resource");

  CORBA::ULong const current_length = this->resources_.length ();

  this->resources_.length (current_length + res.length ());

  for (CORBA::ULong i = 0;i < res.length ();i++)
    {
      this->resources_[current_length + i] = res[i];
    }
}