Skip to content
This repository has been archived by the owner on Jul 22, 2018. It is now read-only.

Commit

Permalink
Rawspeed: CameraMetadata: implement getCamera() with prefix-search.
Browse files Browse the repository at this point in the history
Needed to look for camera with only maker + model known, but no mode.
Here i'm assuming that for all the camera modes we have
the same <ID> name mangling.

This is only needed to de-mangle camera name. *SIGH*

Refs #11108
  • Loading branch information
LebedevRI committed Nov 18, 2016
1 parent 7da551c commit a45724e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
12 changes: 12 additions & 0 deletions RawSpeed/CameraMetaData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,18 @@ Camera* CameraMetaData::getCamera(string make, string model, string mode) {
return cameras[id];
}

Camera* CameraMetaData::getCamera(string make, string model) {
string id = getId(make, model, "");

// do a prefix match, i.e. the make and model match, but not mode.
std::map<string,Camera*>::iterator iter = cameras.lower_bound(id);

if (iter == cameras.find(id))
return NULL;

return cameras[iter->first];
}

bool CameraMetaData::hasCamera(string make, string model, string mode) {
string id = getId(make, model, mode);
if (cameras.end() == cameras.find(id))
Expand Down
6 changes: 6 additions & 0 deletions RawSpeed/CameraMetaData.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,13 @@ class CameraMetaData
virtual ~CameraMetaData(void);
map<string,Camera*> cameras;
map<uint32,Camera*> chdkCameras;

// searches for camera with given make + model + mode
Camera* getCamera(string make, string model, string mode);

// searches for camera with given make + model, with ANY mode
Camera* getCamera(string make, string model);

bool hasCamera(string make, string model, string mode);
Camera* getChdkCamera(uint32 filesize);
bool hasChdkCamera(uint32 filesize);
Expand Down

0 comments on commit a45724e

Please sign in to comment.