1 #include "tao/Compression/Compression_Manager.h"
2 #include "tao/ORB_Constants.h"
4 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
8 CompressionManager::~CompressionManager ()
10 // Require to guard the deletion of the list
11 ACE_GUARD (TAO_SYNCH_MUTEX
, ace_mon
, this->mutex_
);
12 this->factories_
.length (0u);
16 CompressionManager::register_factory (::Compression::CompressorFactory_ptr
19 if (!::CORBA::is_nil (compressor_factory
))
21 ACE_GUARD (TAO_SYNCH_MUTEX
, ace_mon
, this->mutex_
);
22 CORBA::ULong
const length
= this->factories_
.length ();
24 for (CORBA::ULong i
= 0u; i
< length
; ++i
)
26 ::Compression::CompressorId
const current
=
27 this->factories_
[i
]->compressor_id ();
29 if (compressor_factory
->compressor_id () == current
)
31 throw ::Compression::FactoryAlreadyRegistered ();
34 factories_
.length (length
+ 1u);
35 factories_
[length
] = ::Compression::CompressorFactory::_duplicate (
40 // @todo Standardize this minor code
41 throw ::CORBA::BAD_PARAM (CORBA::OMGVMCID
| 44, CORBA::COMPLETED_NO
);
46 CompressionManager::unregister_factory (::Compression::CompressorId
49 ACE_GUARD (TAO_SYNCH_MUTEX
, ace_mon
, this->mutex_
);
50 CORBA::ULong
const length
= this->factories_
.length ();
52 for (CORBA::ULong i
= 0u; i
< length
; ++i
)
54 ::Compression::CompressorId
const current
=
55 this->factories_
[i
]->compressor_id ();
57 if (current
== compressor_id
)
59 // Shuffle down the remainder
62 this->factories_
[i
] = this->factories_
[i
+1u];
65 this->factories_
.length (length
- 1u);
71 throw ::Compression::UnknownCompressorId ();
74 ::Compression::CompressorFactory_ptr
75 CompressionManager::get_factory (::Compression::CompressorId compressor_id
)
77 ACE_GUARD_RETURN (TAO_SYNCH_MUTEX
, ace_mon
, this->mutex_
,
78 ::Compression::CompressorFactory::_nil ());
80 CORBA::ULong
const length
= this->factories_
.length ();
82 for (CORBA::ULong i
= 0u; i
< length
; ++i
)
84 ::Compression::CompressorId
const current
=
85 this->factories_
[i
]->compressor_id ();
87 if (current
== compressor_id
)
89 return ::Compression::CompressorFactory::_duplicate (
94 throw ::Compression::UnknownCompressorId ();
97 ::Compression::Compressor_ptr
98 CompressionManager::get_compressor (::Compression::CompressorId
100 ::Compression::CompressionLevel
103 ::Compression::CompressorFactory_var factory
= this->get_factory (
106 return factory
->get_compressor (compression_level
);
109 ::Compression::CompressorFactorySeq
*
110 CompressionManager::get_factories ()
118 TAO_END_VERSIONED_NAMESPACE_DECL