49 return mySelected.count(
id) > 0;
55 mySelected.insert(
id);
77 const std::set<GUIGlID>&
149 throw ProcessError(
"Unkown object in GUISelectedStorage::toggleSelection (id=" +
toString(
id) +
").");
162 const std::set<GUIGlID>&
168 const std::set<GUIGlID>&
176 for (std::map<GUIGlObjectType, SingleTypeSelections>::iterator it =
mySelections.begin(); it !=
mySelections.end(); it++) {
188 std::set<GUIGlID> result;
189 std::ostringstream msg;
190 std::ifstream strm(filename.c_str());
194 msgOut =
"Could not open '" + filename +
"'.\n";
197 while (strm.good()) {
200 if (line.length() == 0) {
208 if (numIgnored + numMissing <= maxErrors) {
209 msg <<
"Ignoring item '" << line <<
"' because of invalid type " <<
toString(object->
getType()) <<
"\n";
212 result.insert(object->
getGlID());
216 if (numIgnored + numMissing <= maxErrors) {
217 msg <<
"Item '" + line +
"' not found\n";
223 if (numIgnored + numMissing > maxErrors) {
224 msg <<
"...\n" << numIgnored <<
" objects ignored, " << numMissing <<
" objects not found\n";
234 const std::set<GUIGlID> ids =
loadIDs(filename, errors, type);
235 for (std::set<GUIGlID>::const_iterator it = ids.begin(); it != ids.end(); it++) {
272 for (std::set<GUIGlID>::const_iterator i = ids.begin(); i != ids.end(); ++i) {
274 if (
object !=
nullptr) {
@ GLO_NETWORK
The network - empty.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
const std::string & getFullName() const
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
GUIGlID getGlID() const
Returns the numerical id of the object.
void unblockObject(GUIGlID id)
Marks an object as unblocked.
static GUIGlObjectStorage gIDStorage
A single static instance of this class.
GUIGlObject * getObjectBlocking(GUIGlID id)
Returns the object from the container locking it.
void clear()
Clears the list of selected objects.
void select(GUIGlID id)
Adds the object with the given id to the list of selected objects.
const std::set< GUIGlID > & getSelected() const
Returns the list of selected ids.
~SingleTypeSelections()
Destructor.
void deselect(GUIGlID id)
Deselects the object with the given id from the list of selected objects.
SingleTypeSelections()
Constructor.
void save(const std::string &filename)
Saves the list of selected objects to a file named as given.
bool isSelected(GUIGlID id)
Returns the information whether the object with the given id is qithin the selection.
virtual void selectionUpdated()=0
called when selection is updated
void save(GUIGlObjectType type, const std::string &filename)
Saves a selection list.
std::map< GUIGlObjectType, SingleTypeSelections > mySelections
map with the selections
std::string load(const std::string &filename, GUIGlObjectType type=GLO_MAX)
Loads a selection list (optionally with restricted type)
std::set< GUIGlID > myAllSelected
List of selected objects.
~GUISelectedStorage()
Destructor.
void clear()
Clears the list of selected objects.
void toggleSelection(GUIGlID id)
Toggles selection of an object.
void select(GUIGlID id, bool update=true)
Adds the object with the given id.
UpdateTarget * myUpdateTarget
The dialog to be updated.
void add2Update(UpdateTarget *updateTarget)
Adds a dialog to be updated.
void remove2Update()
Removes the dialog to be updated.
std::set< GUIGlID > loadIDs(const std::string &filename, std::string &msgOut, GUIGlObjectType type=GLO_MAX, int maxErrors=16)
Loads a selection list (optionally with restricted type) and returns the ids of all active objects.
bool isSelected(GUIGlObjectType type, GUIGlID id)
Returns the information whether the object with the given type and id is selected.
GUISelectedStorage()
Constructor.
void deselect(GUIGlID id)
Deselects the object with the given id.
const std::set< GUIGlID > & getSelected() const
Returns the set of ids of all selected objects.
Static storage of an output device and its base (abstract) implementation.
void close()
Closes the device and removes it from the dictionary.
static OutputDevice & getDevice(const std::string &name)
Returns the described OutputDevice.