Skip to content

Commit f53fa08

Browse files
author
mark
committed
MMDevice: Make property name available from Property object (Jon Daniels)
(No change to device interface.) git-svn-id: https://valelab.ucsf.edu/svn/micromanager2/trunk@15892 d0ab736e-dc22-4aeb-8dc9-08def0aa14fd
1 parent a14b763 commit f53fa08

2 files changed

Lines changed: 33 additions & 17 deletions

File tree

MMDevice/Property.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -340,21 +340,20 @@ int MM::PropertyCollection::CreateProperty(const char* pszName, const char* pszV
340340

341341
switch(eType)
342342
{
343-
case MM::String:
344-
pProp = new MM::StringProperty();
345-
break;
346-
343+
case MM::String:
344+
pProp = new MM::StringProperty(pszName);
345+
break;
346+
347347
case MM::Integer:
348-
pProp = new MM::IntegerProperty();
349-
break;
348+
pProp = new MM::IntegerProperty(pszName);
349+
break;
350350

351351
case MM::Float:
352-
pProp = new MM::FloatProperty();
353-
break;
352+
pProp = new MM::FloatProperty(pszName);
353+
break;
354354

355355
default:
356-
return DEVICE_INVALID_PROPERTY_TYPE; // unsupported type
357-
break;
356+
return DEVICE_INVALID_PROPERTY_TYPE;
358357
}
359358

360359
if (!pProp->Set(pszValue))

MMDevice/Property.h

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ class PropertyBase
6767
virtual int AddToSequence(const char* value) = 0;
6868
virtual int SendSequence() = 0;
6969

70+
virtual std::string GetName() const = 0;
7071
};
7172

7273
/**
@@ -125,7 +126,7 @@ class ActionEx : public ActionFunctor
125126
class Property : public PropertyBase
126127
{
127128
public:
128-
Property() :
129+
Property(const char* name) :
129130
readOnly_(false),
130131
fpAction_(0),
131132
cached_(false),
@@ -136,13 +137,15 @@ class Property : public PropertyBase
136137
sequenceMaxSize_(0),
137138
sequenceEvents_(),
138139
lowerLimit_(0.0),
139-
upperLimit_(0.0)
140-
{}
140+
upperLimit_(0.0),
141+
name_(name)
142+
{}
143+
141144
virtual ~Property()
142145
{
143146
delete fpAction_;
144147
}
145-
148+
146149
bool GetCached()const {return cached_;}
147150
void SetCached(bool bState=true) {cached_ = bState;}
148151

@@ -264,6 +267,11 @@ class Property : public PropertyBase
264267
return DEVICE_OK; // Return an error instead???
265268
}
266269

270+
std::string GetName() const
271+
{
272+
return name_;
273+
}
274+
267275
std::vector<std::string> GetSequence() const
268276
{
269277
return sequenceEvents_;
@@ -296,6 +304,7 @@ class Property : public PropertyBase
296304
double lowerLimit_;
297305
double upperLimit_;
298306
std::map<std::string, long> values_; // allowed values
307+
const std::string name_;
299308

300309
private:
301310
Property& operator=(const Property&);
@@ -307,7 +316,9 @@ class Property : public PropertyBase
307316
class StringProperty : public Property
308317
{
309318
public:
310-
StringProperty() : Property() {}
319+
StringProperty(const char* name) :
320+
Property(name)
321+
{}
311322
virtual ~StringProperty(){};
312323

313324
PropertyType GetType() {return String;}
@@ -335,7 +346,10 @@ class StringProperty : public Property
335346
class FloatProperty : public Property
336347
{
337348
public:
338-
FloatProperty(): Property(), value_(0.0), decimalPlaces_(4)
349+
FloatProperty(const char* name) :
350+
Property(name),
351+
value_(0.0),
352+
decimalPlaces_(4)
339353
{
340354
int rms = 1;
341355
for (int i = 0; i < decimalPlaces_; ++i)
@@ -375,7 +389,10 @@ class FloatProperty : public Property
375389
class IntegerProperty : public Property
376390
{
377391
public:
378-
IntegerProperty(): Property(), value_(0) {}
392+
IntegerProperty(const char* name) :
393+
Property(name),
394+
value_(0)
395+
{}
379396
~IntegerProperty() {};
380397

381398
PropertyType GetType() {return Integer;}

0 commit comments

Comments
 (0)