Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / TAO / tao / Compression / Compression_Manager.cpp
blobe28f98bc21a5dcc9c892cc21af757cac6b69c54c
1 #include "tao/Compression/Compression_Manager.h"
2 #include "tao/ORB_Constants.h"
4 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
6 namespace TAO
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);
15 void
16 CompressionManager::register_factory (::Compression::CompressorFactory_ptr
17 compressor_factory)
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 (
36 compressor_factory);
38 else
40 // @todo Standardize this minor code
41 throw ::CORBA::BAD_PARAM (CORBA::OMGVMCID | 44, CORBA::COMPLETED_NO);
45 void
46 CompressionManager::unregister_factory (::Compression::CompressorId
47 compressor_id)
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
60 while (i < length-1u)
62 this->factories_[i] = this->factories_[i+1u];
63 ++i;
65 this->factories_.length (length - 1u);
66 return;
70 // todo exception
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 (
90 this->factories_[i]);
94 throw ::Compression::UnknownCompressorId ();
97 ::Compression::Compressor_ptr
98 CompressionManager::get_compressor (::Compression::CompressorId
99 compressor_id,
100 ::Compression::CompressionLevel
101 compression_level)
103 ::Compression::CompressorFactory_var factory = this->get_factory (
104 compressor_id);
106 return factory->get_compressor (compression_level);
109 ::Compression::CompressorFactorySeq *
110 CompressionManager::get_factories ()
112 // todo
113 return 0;
118 TAO_END_VERSIONED_NAMESPACE_DECL