5 auto p = [id](
const std::shared_ptr<AbstractElement>& e) {
6 return e->getId() == id;
8 auto element = std::find_if(entries.begin(), entries.end(), p);
9 return element != entries.end() ? (*element).get() :
nullptr;
13 return &(this->entries);
17 std::stringstream stream;
18 stream <<
"Block " << this->prototype.
blockName <<
":\n";
19 for (
const auto& entry: entries) {
20 stream << entry->toString();
28 std::map<BlockName, DBNode::Value> elts_as_nodes;
29 for (
const auto& elt : this->entries) {
30 elts_as_nodes.emplace(elt->getId().to_string(), elt->toDBNode());
32 if (!this->entries.empty() && this->prototype.
globalScale) {
33 double scale = entries[0]->getScale();
34 node.
set(scale,
"scale");
37 return std::make_shared<DBNode>(node);
42 this->entries.emplace_back(std::move(elt));
46 for (
auto line : lines) {
54 for (
const auto& e : this->entries) {
55 if (e->getId() == id)
return true;
#define LOG_DEBUG(...)
Macro for logging debug messages.
Abstract base class for a single element of an LHA/FLHA block.
void setGroup(const std::vector< BlockName > &keys, const std::map< BlockName, Value > &groupData)
Sets the content of a whole sub-tree from a map of values.
void set(T value, Key &&key, Rest &&... rest)
Sets a value in the node using a sequence of keys.
std::string toString() const
Serializes the block and all its entries to a string.
AbstractElement * get(const LhaID &id) const
Retrieves an element by its identifier.
const std::vector< std::shared_ptr< AbstractElement > > * getEntries() const
Returns a read-only view of all entries in the block.
bool hasElement(const LhaID &id) const
Checks whether an element is present in the block.
void addElement(const std::vector< std::string > &line)
Adds a new element to the block from a line of data.
void readData(const std::vector< std::vector< std::string > > &lines)
Reads data and populates the block with elements from raw lines.
std::shared_ptr< DBNode > toDBNode() const
Converts the block and its entries to a DBNode representation.
static std::shared_ptr< AbstractElement > createElement(const Prototype &prototype, const std::vector< std::string > &line)
Creates an element of the appropriate type for a given line.
Representation of a single LHA/FLHA block and its entries.
Represents an identifier of a LHA element, possibly containing several sub-ids.