Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds feature attributes to class selection example #8

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 25 additions & 23 deletions src/FeatureVirtualInheritance/FVImain.cpp
Original file line number Diff line number Diff line change
@@ -1,37 +1,39 @@
#include "fpcsc/perf_util/sleep.h"
#include "fpcsc/perf_util/feature_cmd.h"
#include "fpcsc/perf_util/sleep.h"

class FeatureGroup {
class __attribute__((feature_variable("FeatureGroup"))) FeatureGroup {
public:
virtual void doWork() {
fpcsc::sleep_for_secs(5);
}
virtual void doWork() { fpcsc::sleep_for_secs(5); }

virtual ~FeatureGroup() = default;
};

class FValue1 : public FeatureGroup {
void doWork() override {
fpcsc::sleep_for_secs(1);
}
class __attribute__((feature_variable("FValue1"))) FValue1
: public FeatureGroup {
public:
void doWork() override { fpcsc::sleep_for_secs(1); }
};

class FValue2 : public FeatureGroup {
void doWork() override {
fpcsc::sleep_for_secs(2);
}
class __attribute__((feature_variable("FValue2"))) FValue2
: public FeatureGroup {
public:
void doWork() override { fpcsc::sleep_for_secs(2); }
};

class FValue3 : public FeatureGroup {
void doWork() override {
fpcsc::sleep_for_secs(3);
}
class __attribute__((feature_variable("FValue3"))) FValue3
: public FeatureGroup {
public:
void doWork() override { fpcsc::sleep_for_secs(3); }
};

class FValueOther : public FeatureGroup {};
// This should not appear in traces as there is no implementation different
// from the base class
class __attribute__((feature_variable("FValueOther"))) FValueOther
: public FeatureGroup {};

int main(int argc, char *argv[]) {
FeatureGroup *feature;
FeatureGroup *feature __attribute__((feature_variable("FG_variable"))) =
nullptr;

if (fpcsc::isFeatureEnabled(argc, argv, std::string("--value1"))) {
feature = new FValue1();
Expand All @@ -43,10 +45,10 @@ int main(int argc, char *argv[]) {
feature = new FValueOther();
}

if (feature) {
feature->doWork(); // Feature dependent time cost

feature->doWork(); // Feature dependent time cost


delete feature;
delete feature;
}
return 0;
}