Scanframe Modular Application 0.1.0
Loading...
Searching...
No Matches
CustomFields.h
Go to the documentation of this file.
1#pragma once
2
3#include "Namespace.h"
5#include "gii/gen/Variable.h"
6#include "misc/gen/Sustain.h"
7
8namespace sf
9{
10
12{
13 public:
14 // Constructor.
15 CustomFields(TPartInspection* pi, const std::string& prefix, id_type id_offset, id_type id_range);
16 // Destructor.
17 ~CustomFields() override;
18 // Sets the variables to be exported.
19 bool SetExport(bool exported);
20 // Returns true when variables are exported.
21 bool IsExported() const;
22 // Returns if during the last reading of values some are not filled in.
23 // This is always the case with new inspection ore when a configuration has changed.
24 bool IsComplete() const;
25 // Set or resets the complete flag.
26 void SetComplete(bool yn);
27 // Returns the amount of entries
28 int GetCount() const;
29 // Swaps two entries.
30 void Swap(int index1, int index2);
31 // Adds an empty entry to the list.
32 void Add();
33 // Adds an entry to the list.
34 void Add(const std::string& name, const std::string& setup);
35 // Flushes the list.
36 void Clear();
37 // Returns the name of the field.
38 std::string GetName(int index) const;
39 // Returns the setup of the variable.
40 std::string GetSetup(int index) const;
41 // Functions to read the configuration from profile.
42 void ReadWriteConfig(IniProfile* ini, bool rd);
43 // Functions to read the configuration from the default module profile.
44 void ReadWriteConfig(bool rd);
45 // Write the custom values to the inspection file.
46 bool ReadWriteValues(bool rd);
47 // Returns the filed values to their default value.
49 // Returns true when modified.
50 bool IsDirty() const;
51 // Sets or resets the dirty flag.
52 void SetDirty(bool dirty);
53 // Returns the configuration in strings.
54 void GetStrings(KeyValues& list);
55 // Sets the configuration from strings.
56 void SetStrings(const KeyValues& list);
57
58 protected:
59 // Handler for variables
60 void variableEventHandler(EEvent event, const Variable& caller, Variable& link, bool same_inst) override;
61
62 // Function called be the sustain hook.
63 bool Sustain(const timespec&);
64
65 private:
66 // Hook to the sustain interface.
67 TSustain<CustomFields> FSustainEntry;
68 // Holds the created variables.
70 // Holds the offset and range for this.
71 id_type FIdOffset, FIdRange;
72 // Holds the prefix name of the variables.
73 std::string FNamePrefix;
74 // Holds the dirty flag.
75 bool FDirty;
76 // Holds the export flag.
77 bool FIsExported;
78 // Holds the flag if there are any open not filled in fields during reading.
79 bool FIsComplete;
80 // Holds the flag on whether anything has changed.
81 bool FChanged;
82 // Holds the part inspection pointer.
83 TPartInspection* FPartInspection;
84};
85
86inline bool CustomFields::IsDirty() const
87{
88 return FDirty;
89}
90
91inline void CustomFields::SetComplete(bool yn)
92{
93 FIsComplete = yn;
94}
95
96inline bool CustomFields::IsComplete() const
97{
98 return FIsComplete;
99}
100
101inline bool CustomFields::IsExported() const
102{
103 return FIsExported;
104}
105
106inline void CustomFields::SetDirty(bool dirty)
107{
108 FDirty = dirty;
109}
110
111inline int CustomFields::GetCount() const
112{
113 return FVars.count();
114}
115
116inline std::string CustomFields::GetName(int index) const
117{
118 return *(FVars[index]->getData<std::string*>());
119}
120
121inline std::string CustomFields::GetSetup(int index) const
122{
123 return FVars[index]->getSetupString();
124}
125
126}// namespace sf
Definition CustomFields.h:12
void Add(const std::string &name, const std::string &setup)
bool SetExport(bool exported)
bool ReadWriteValues(bool rd)
std::string GetName(int index) const
Definition CustomFields.h:116
void GetStrings(KeyValues &list)
void Swap(int index1, int index2)
void SetStrings(const KeyValues &list)
void ReadWriteConfig(IniProfile *ini, bool rd)
std::string GetSetup(int index) const
Definition CustomFields.h:121
int GetCount() const
Definition CustomFields.h:111
void SetDirty(bool dirty)
Definition CustomFields.h:106
~CustomFields() override
void ReadWriteConfig(bool rd)
bool IsExported() const
Definition CustomFields.h:101
void variableEventHandler(EEvent event, const Variable &caller, Variable &link, bool same_inst) override
Pure virtual function which must be implemented when used in a polymorphic setting.
CustomFields(TPartInspection *pi, const std::string &prefix, id_type id_offset, id_type id_range)
bool IsComplete() const
Definition CustomFields.h:96
void SetComplete(bool yn)
Definition CustomFields.h:91
bool Sustain(const timespec &)
bool IsDirty() const
Definition CustomFields.h:86
unsigned long long id_type
Type used for the identifying integer (64-bits).
Definition InformationBase.h:30
Class for reading and writing ini-profiles.
Definition IniProfile.h:17
Definition PartInspection.h:11
Template to make the sustain system call a class method regularly.
Definition Sustain.h:184
size_type count() const
Returns the amount of entries in the vector.
Base class used for giving a Variable instance access to a member functions of a derived class....
Definition VariableHandler.h:14
EEvent
Events send to the handler set with sf::Variable::setHandler.
Definition VariableTypes.h:130
Class for creating and referencing global or local created parameters or settings called variables....
Definition Variable.h:16
Definition Application.h:10
IniProfile::KeyValueMap KeyValues
Definition ipj/iface/Namespace.h:188