t/cookbook/recipe04.xsi

filter: Statementstmt 0.0% 0 / 11 Branchbran 0.0% 0 / 18 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 0.0% 0 / 29 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« t/cookbook/recipe03.xsi ↑ Summary t/cookbook/recipe05.xsi »
1 MODE: INLINE
2  
3 #include <iostream>
4 #include <memory>
5  
6 struct TimezoneRecipe04 {
7 const char* get_name() const { return name.c_str(); }
8 static std::shared_ptr<TimezoneRecipe04> create(const char* name) {
9 return std::make_shared<TimezoneRecipe04>(name);
10 }
11 TimezoneRecipe04(const char* name_): name{name_} { }
12 ~TimezoneRecipe04() { std::cout << "~TimezoneRecipe04()\n"; }
13 private:
14 std::string name;
15 };
16  
17 using TimezoneRecipe04SP = std::shared_ptr<TimezoneRecipe04>;
18  
19 namespace xs {
20 template <>
21 struct Typemap<TimezoneRecipe04SP> : TypemapObject<TimezoneRecipe04SP, TimezoneRecipe04SP, ObjectTypeSharedPtr, ObjectStorageMG, StaticCast> {
22 static std::string package () { return "MyTest::Cookbook::TimezoneRecipe04"; }
23 };
24 }
25  
26 struct DateRecipe04 {
27 DateRecipe04() { update() ; }
28 void update() { epoch = std::time(nullptr); }
29  
30 int get_epoch() const { return epoch; }
31 void set_timezone(TimezoneRecipe04SP tz_) { tz = tz_; }
32 TimezoneRecipe04SP get_timezone() { return tz; }
33 private:
34 std::time_t epoch;
35 TimezoneRecipe04SP tz;
36 };
37  
38 namespace xs {
39 template <>
40 struct Typemap<DateRecipe04*> : TypemapObject<DateRecipe04*, DateRecipe04*, ObjectTypePtr, ObjectStorageMG, StaticCast> {
41 static std::string package () { return "MyTest::Cookbook::DateRecipe04"; }
42 };
43 }
44  
45 MODULE = MyTest::Cookbook PACKAGE = MyTest::Cookbook::TimezoneRecipe04
46 PROTOTYPES: DISABLE
47  
48 0 const char* get_name(TimezoneRecipe04SP tz) { RETVAL = tz->get_name(); }
49  
50 0 TimezoneRecipe04SP create(const char* name) { RETVAL = TimezoneRecipe04::create(name); }
51 0 ▶ 
Branch: 2 branches
BranchTrueFalseTotal
0 0 0
0 0 0
52 MODULE = MyTest::Cookbook PACKAGE = MyTest::Cookbook::DateRecipe04
53 PROTOTYPES: DISABLE
54  
55 0 DateRecipe04* DateRecipe04::new() { RETVAL = new DateRecipe04(); }
56 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
0 0 0
57 0 ▶void DateRecipe04::update()
Branch: 4 branches
BranchTrueFalseTotal
void DateRecipe04::update() 0 0 0
void DateRecipe04::update() 0 0 0
void DateRecipe04::update() 0 0 0
void DateRecipe04::update() 0 0 0
58  
59 0 std::time_t DateRecipe04::get_epoch()
60 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
0 0 0
61 0 TimezoneRecipe04SP DateRecipe04::get_timezone()
62 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
0 0 0
63 0 void DateRecipe04::set_timezone(TimezoneRecipe04SP tz)
« t/cookbook/recipe03.xsi ↑ Summary t/cookbook/recipe05.xsi »