mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
Switches to the new build system (#87)
* Removes old build system * Removes old gmock * Adds new gmock * Moves source files to new locations * Adds new build system
This commit is contained in:
committed by
Peter Johnson
parent
9d45088127
commit
133540f577
76
src/main/native/cpp/PropertyImpl.h
Normal file
76
src/main/native/cpp/PropertyImpl.h
Normal file
@@ -0,0 +1,76 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2016. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef CS_PROPERTYIMPL_H_
|
||||
#define CS_PROPERTYIMPL_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "llvm/StringRef.h"
|
||||
|
||||
#include "cscore_c.h"
|
||||
|
||||
namespace cs {
|
||||
|
||||
// Property data
|
||||
class PropertyImpl {
|
||||
public:
|
||||
PropertyImpl() = default;
|
||||
PropertyImpl(llvm::StringRef name_) : name{name_} {}
|
||||
PropertyImpl(llvm::StringRef name_, CS_PropertyKind kind_, int step_,
|
||||
int defaultValue_, int value_)
|
||||
: name{name_},
|
||||
propKind{kind_},
|
||||
step{step_},
|
||||
defaultValue{defaultValue_},
|
||||
value{value_} {}
|
||||
virtual ~PropertyImpl() = default;
|
||||
PropertyImpl(const PropertyImpl& oth) = delete;
|
||||
PropertyImpl& operator=(const PropertyImpl& oth) = delete;
|
||||
|
||||
void SetValue(int v) {
|
||||
if (hasMinimum && v < minimum)
|
||||
value = minimum;
|
||||
else if (hasMaximum && v > maximum)
|
||||
value = maximum;
|
||||
else
|
||||
value = v;
|
||||
valueSet = true;
|
||||
}
|
||||
|
||||
void SetValue(llvm::StringRef v) {
|
||||
valueStr = v;
|
||||
valueSet = true;
|
||||
}
|
||||
|
||||
void SetDefaultValue(int v) {
|
||||
if (hasMinimum && v < minimum)
|
||||
defaultValue = minimum;
|
||||
else if (hasMaximum && v > maximum)
|
||||
defaultValue = maximum;
|
||||
else
|
||||
defaultValue = v;
|
||||
}
|
||||
|
||||
std::string name;
|
||||
CS_PropertyKind propKind{CS_PROP_NONE};
|
||||
bool hasMinimum{false};
|
||||
bool hasMaximum{false};
|
||||
int minimum{0};
|
||||
int maximum{100};
|
||||
int step{1};
|
||||
int defaultValue{0};
|
||||
int value{0};
|
||||
std::string valueStr;
|
||||
std::vector<std::string> enumChoices;
|
||||
bool valueSet{false};
|
||||
};
|
||||
|
||||
} // namespace cs
|
||||
|
||||
#endif // CS_PROPERTYIMPL_H_
|
||||
Reference in New Issue
Block a user