mirror of
https://github.com/opencv/opencv.git
synced 2025-01-18 14:13:15 +08:00
Made Filestorage able to not own its CvFileStorage instance.
This allows to get rid of the last remaining Ptr<T>::addref calls.
This commit is contained in:
parent
3e189a2b41
commit
a50d75d362
@ -186,7 +186,7 @@ public:
|
|||||||
//! the full constructor that opens file storage for reading or writing
|
//! the full constructor that opens file storage for reading or writing
|
||||||
CV_WRAP FileStorage(const String& source, int flags, const String& encoding=String());
|
CV_WRAP FileStorage(const String& source, int flags, const String& encoding=String());
|
||||||
//! the constructor that takes pointer to the C FileStorage structure
|
//! the constructor that takes pointer to the C FileStorage structure
|
||||||
FileStorage(CvFileStorage* fs);
|
FileStorage(CvFileStorage* fs, bool owning=true);
|
||||||
//! the destructor. calls release()
|
//! the destructor. calls release()
|
||||||
virtual ~FileStorage();
|
virtual ~FileStorage();
|
||||||
|
|
||||||
|
@ -5129,9 +5129,11 @@ FileStorage::FileStorage(const String& filename, int flags, const String& encodi
|
|||||||
open( filename, flags, encoding );
|
open( filename, flags, encoding );
|
||||||
}
|
}
|
||||||
|
|
||||||
FileStorage::FileStorage(CvFileStorage* _fs)
|
FileStorage::FileStorage(CvFileStorage* _fs, bool owning)
|
||||||
{
|
{
|
||||||
fs = Ptr<CvFileStorage>(_fs);
|
if (owning) fs.reset(_fs);
|
||||||
|
else fs = Ptr<CvFileStorage>(Ptr<CvFileStorage>(), _fs);
|
||||||
|
|
||||||
state = _fs ? NAME_EXPECTED + INSIDE_MAP : UNDEFINED;
|
state = _fs ? NAME_EXPECTED + INSIDE_MAP : UNDEFINED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,13 +85,12 @@ void CvEM::read( CvFileStorage* fs, CvFileNode* node )
|
|||||||
|
|
||||||
void CvEM::write( CvFileStorage* _fs, const char* name ) const
|
void CvEM::write( CvFileStorage* _fs, const char* name ) const
|
||||||
{
|
{
|
||||||
FileStorage fs = _fs;
|
FileStorage fs(_fs, false);
|
||||||
if(name)
|
if(name)
|
||||||
fs << name << "{";
|
fs << name << "{";
|
||||||
emObj.write(fs);
|
emObj.write(fs);
|
||||||
if(name)
|
if(name)
|
||||||
fs << "}";
|
fs << "}";
|
||||||
fs.fs.obj = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
double CvEM::calcLikelihood( const Mat &input_sample ) const
|
double CvEM::calcLikelihood( const Mat &input_sample ) const
|
||||||
|
@ -1353,8 +1353,7 @@ public:
|
|||||||
{
|
{
|
||||||
if(ptr && _fs)
|
if(ptr && _fs)
|
||||||
{
|
{
|
||||||
FileStorage fs(_fs);
|
FileStorage fs(_fs, false);
|
||||||
fs.fs.addref();
|
|
||||||
((const _ClsName*)ptr)->write(fs, String(name));
|
((const _ClsName*)ptr)->write(fs, String(name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user