Skip to content

Commit

Permalink
make package routines virtual
Browse files Browse the repository at this point in the history
  • Loading branch information
gonuke committed Mar 21, 2024
1 parent 69d38ad commit 43063b6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/material.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,11 @@ class Material: public Resource {
/// DEPRECATED - use non-const comp() function.
Composition::Ptr comp() const;

int package_id();
virtual int package_id();

/// Changes the package id. Checks that the resource fits the package
/// type minimum and maximum mass criteria.
void ChangePackageId(int new_package_id = default_package_id_);
virtual void ChangePackageId(int new_package_id = default_package_id_);

protected:
Material(Context* ctx, double quantity, Composition::Ptr c, int package_id = default_package_id_);
Expand Down
6 changes: 3 additions & 3 deletions src/product.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ class Product : public Resource {
/// @throws ValueError 'other' resource is of different quality
void Absorb(Product::Ptr other);

// Returns the package id.
int package_id();
/// Returns the package id.
virtual int package_id();

/// Changes the product's package id
void ChangePackageId(int new_package_id = default_package_id_);
virtual void ChangePackageId(int new_package_id = default_package_id_);

private:
/// @param ctx the simulation context
Expand Down
6 changes: 6 additions & 0 deletions src/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ class Resource {
/// @param res pointer to a resource to be absorbed by this resource
virtual void Absorb(Ptr res) { throw Error("cannot absorb resource type " + this->type()); };

/// Returns the package id.
virtual int package_id() = 0;

/// Changes the product's package id
virtual void ChangePackageId(int new_package_id) = 0;

protected:
const static int default_package_id_ = 1;
private:
Expand Down

0 comments on commit 43063b6

Please sign in to comment.