Files
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

115 lines
2.9 KiB
C++

// Example program for matching summary functions and synthetic child providers.
//
// The classes here simulate code generated by a serialization tool like, for
// example, protocol buffers. But the actual "generated" class layout is
// extremely naive to simplify the example.
//
// The idea is that we want to have generic formatters for a bunch of message
// classes, because they are all generated following common patterns, but the
// matching can't be based in the type name, because it can be anything.
#include <string>
class Message {
// Dummy method definitions to illustrate a possible generic message API.
std::string serialize() { return "TODO"; }
Message* deserialize() {
return nullptr; // TODO.
}
};
// This class could have been generated from a description like this. Assume
// fields are always optional, for simplicity (e.g. we don't care during
// serialization if a Customer has a name or not, we're just moving data around
// and validation happens elsewhere).
//
// message Customer {
// string name;
// int age;
// string address;
// }
class Customer : public Message {
private:
int _internal_bookkeeping_bits_;
// Presence bits. They are true if the field has been set.
bool _has_name_ = false;
bool _has_age_ = false;
bool _has_address_ = false;
// Actual field data.
std::string name_;
int age_;
std::string address_;
public:
// Getters and setters.
bool has_name() { return _has_name_; }
bool has_age() { return _has_age_; }
bool has_address() { return _has_address_; }
std::string name() { return name_; }
int age() { return age_; }
std::string address() { return address_; }
void set_name(std::string name) {
name_ = name;
_has_name_ = true;
}
void set_age(int age) {
age_ = age;
_has_age_ = true;
}
void set_address(std::string address) {
address_ = address;
_has_address_ = true;
}
};
// message ProductOrder {
// string product_name;
// int amount;
// }
class ProductOrder : public Message {
private:
int _internal_bookkeeping_bits_;
// Presence bits. They are true if the field has been set.
bool _has_product_name_ = false;
bool _has_amount_ = false;
// Actual field data.
std::string product_name_;
int amount_;
public:
// Getters and setters.
bool has_product_name() { return _has_product_name_; }
bool has_amount() { return _has_amount_; }
std::string get_product_name() { return product_name_; }
int get_amount() { return amount_; }
void set_product_name(std::string product_name) {
product_name_ = product_name;
_has_product_name_ = true;
}
void set_amount(int amount) {
amount_ = amount;
_has_amount_ = true;
}
};
int main(int argc, char **argv) {
Customer customer;
customer.set_name("C. Ustomer");
customer.set_address("123 Fake St.");
// no age, so we can check absent fields get omitted.
ProductOrder order;
order.set_product_name("widget");
order.set_amount(100);
return 0; // break here.
}