Skip to content

Commit

Permalink
Merge branch 'feature/modernisation_merge_accessor_classes' of github…
Browse files Browse the repository at this point in the history
….com:ecmwf/eccodes into feature/modernisation_merge_accessor_classes
  • Loading branch information
joobog committed Oct 4, 2024
2 parents 376b7e7 + 859399d commit 7ee915b
Show file tree
Hide file tree
Showing 108 changed files with 1,554 additions and 1,510 deletions.
4 changes: 1 addition & 3 deletions src/accessor/grib_accessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ class grib_accessor
virtual grib_accessor* next_accessor() = 0;
virtual void resize(size_t new_size) = 0;
virtual void destroy(grib_context* ct) = 0;

virtual int compare_accessors(grib_accessor* a2, int compare_flags);
virtual int compare(grib_accessor*) = 0;
virtual int add_attribute(grib_accessor* attr, int nest_if_clash);
Expand All @@ -78,8 +77,7 @@ class grib_accessor
virtual grib_accessor* make_clone(grib_section*, int*) = 0;

public:
// private:
// TODO(maee): make members private
// TODO(maee): make private
grib_context* context_;
const char* name_; /** < name of the accessor */
const char* class_name_; /** < name of the class (Artifact from C version of ecCodes) */
Expand Down
1 change: 1 addition & 0 deletions src/accessor/grib_accessor_class_abstract_long_vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class grib_accessor_abstract_long_vector_t : public grib_accessor_gen_t
grib_accessor* create_empty_accessor() override { return new grib_accessor_abstract_long_vector_t{}; }

public:
// TODO(maee): make private
long* v_;
long pack_index_;
int number_of_elements_;
Expand Down
1 change: 1 addition & 0 deletions src/accessor/grib_accessor_class_abstract_vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class grib_accessor_abstract_vector_t : public grib_accessor_double_t
grib_accessor* create_empty_accessor() override { return new grib_accessor_abstract_vector_t{}; }

public:
// TODO(maee): make private
double* v_;
int number_of_elements_;
};
21 changes: 10 additions & 11 deletions src/accessor/grib_accessor_class_bitmap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,22 @@
grib_accessor_bitmap_t _grib_accessor_bitmap{};
grib_accessor* grib_accessor_bitmap = &_grib_accessor_bitmap;

static void compute_size(grib_accessor* a)
void grib_accessor_bitmap_t::compute_size()
{
grib_accessor_bitmap_t* self = (grib_accessor_bitmap_t*)a;
long slen = 0;
long off = 0;
grib_handle* hand = grib_handle_of_accessor(a);
grib_handle* hand = grib_handle_of_accessor(this);

grib_get_long_internal(hand, self->offsetbsec_, &off);
grib_get_long_internal(hand, self->sLength_, &slen);
grib_get_long_internal(hand, offsetbsec_, &off);
grib_get_long_internal(hand, sLength_, &slen);

if (slen == 0) {
grib_accessor* seclen;
size_t size;
/* Assume reparsing */
Assert(hand->loader != 0);
if (hand->loader != 0) {
seclen = grib_find_accessor(hand, self->sLength_);
seclen = grib_find_accessor(hand, sLength_);
Assert(seclen);
grib_get_block_length(seclen->parent_, &size);
slen = size;
Expand All @@ -39,15 +38,15 @@ static void compute_size(grib_accessor* a)

// printf("compute_size off=%ld slen=%ld a->offset_=%ld\n", (long)off,(long)slen,(long)offset_ );

a->length_ = off + (slen - a->offset_);
length_ = off + (slen - offset_);

if (a->length_ < 0) {
if (length_ < 0) {
/* Assume reparsing */
/*Assert(hand->loader != 0);*/
a->length_ = 0;
length_ = 0;
}

Assert(a->length_ >= 0);
Assert(length_ >= 0);
}

void grib_accessor_bitmap_t::init(const long len, grib_arguments* arg)
Expand All @@ -61,7 +60,7 @@ void grib_accessor_bitmap_t::init(const long len, grib_arguments* arg)
offsetbsec_ = grib_arguments_get_name(hand, arg, n++);
sLength_ = grib_arguments_get_name(hand, arg, n++);

compute_size(this);
compute_size();
}

long grib_accessor_bitmap_t::next_offset()
Expand Down
10 changes: 7 additions & 3 deletions src/accessor/grib_accessor_class_bitmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,14 @@ class grib_accessor_bitmap_t : public grib_accessor_bytes_t
void update_size(size_t) override;
int unpack_double_element(size_t i, double* val) override;
int unpack_double_element_set(const size_t* index_array, size_t len, double* val_array) override;
// TODO(maee): make members private
public:
const char* tableReference_;

protected:
const char* missing_value_;

private:
const char* tableReference_;
const char* offsetbsec_;
const char* sLength_;

void compute_size();
};
Loading

0 comments on commit 7ee915b

Please sign in to comment.