/* Copyright (c) 2005-2021 Intel Corporation Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #ifndef tbb_test_join_node_H #define tbb_test_join_node_H #if _MSC_VER // Suppress "decorated name length exceeded, name was truncated" warning #if __INTEL_COMPILER #pragma warning( disable: 2586 ) #else #pragma warning( disable: 4503 ) #endif #endif #include "tbb/flow_graph.h" #include "common/test.h" #include "common/utils.h" #include "common/checktype.h" #include "common/graph_utils.h" #include "common/test_follows_and_precedes_api.h" #include const char *names[] = { "Adam", "Bruce", "Charles", "Daniel", "Evan", "Frederich", "George", "Hiram", "Ichabod", "John", "Kevin", "Leonard", "Michael", "Ned", "Olin", "Paul", "Quentin", "Ralph", "Steven", "Thomas", "Ulysses", "Victor", "Walter", "Xerxes", "Yitzhak", "Zebediah", "Anne", "Bethany", "Clarisse", "Dorothy", "Erin", "Fatima", "Gabrielle", "Helen", "Irene", "Jacqueline", "Katherine", "Lana", "Marilyn", "Noelle", "Okiilani", "Pauline", "Querida", "Rose", "Sybil", "Tatiana", "Umiko", "Victoria", "Wilma", "Xena", "Yolanda", "Zoe", "Algernon", "Benjamin", "Caleb", "Dylan", "Ezra", "Felix", "Gabriel", "Henry", "Issac", "Jasper", "Keifer", "Lincoln", "Milo", "Nathaniel", "Owen", "Peter", "Quincy", "Ronan", "Silas", "Theodore", "Uriah", "Vincent", "Wilbur", "Xavier", "Yoda", "Zachary", "Amelia", "Brielle", "Charlotte", "Daphne", "Emma", "Fiona", "Grace", "Hazel", "Isla", "Juliet", "Keira", "Lily", "Mia", "Nora", "Olivia", "Penelope", "Quintana", "Ruby", "Sophia", "Tessa", "Ursula", "Violet", "Willow", "Xanthe", "Yvonne", "ZsaZsa", "Asher", "Bennett", "Connor", "Dominic", "Ethan", "Finn", "Grayson", "Hudson", "Ian", "Jackson", "Kent", "Liam", "Matthew", "Noah", "Oliver", "Parker", "Quinn", "Rhys", "Sebastian", "Taylor", "Umberto", "Vito", "William", "Xanto", "Yogi", "Zane", "Ava", "Brenda", "Chloe", "Delilah", "Ella", "Felicity", "Genevieve", "Hannah", "Isabella", "Josephine", "Kacie", "Lucy", "Madeline", "Natalie", "Octavia", "Piper", "Qismah", "Rosalie", "Scarlett", "Tanya", "Uta", "Vivian", "Wendy", "Xola", "Yaritza", "Zanthe"}; static const int NameCnt = sizeof(names)/sizeof(char *); template struct index_to_key { K operator()(const int indx) { return (K)(3*indx+1); } }; template<> struct index_to_key { std::string operator()(const int indx) { return std::string(names[indx % NameCnt]); } }; template struct K_deref { typedef K type; }; template struct K_deref { typedef K type; }; template struct MyKeyFirst { K my_key; V my_value; MyKeyFirst(int i = 0, int v = 0): my_key(index_to_key()(i)), my_value((V)v) { } void print_val() const { INFO("MyKeyFirst{"); print_my_value(my_key); INFO(","); print_my_value(my_value); INFO("}"); } operator int() const { return (int)my_value; } }; template struct MyKeySecond { V my_value; K my_key; MyKeySecond(int i = 0, int v = 0): my_value((V)v), my_key(index_to_key()(i)) { } void print_val() const { INFO("MyKeySecond{"); print_my_value(my_key); INFO(","); print_my_value(my_value); INFO("}"); } operator int() const { return (int)my_value; } }; template struct MyMessageKeyWithoutKey { V my_value; K my_message_key; MyMessageKeyWithoutKey(int i = 0, int v = 0): my_value((V)v), my_message_key(index_to_key()(i)) { } void print_val() const { INFO("MyMessageKeyWithoutKey{"); print_my_value(my_message_key); INFO(","); print_my_value(my_value); INFO("}"); } operator int() const { return (int)my_value; } const K& key() const { return my_message_key; } }; template struct MyMessageKeyWithBrokenKey { V my_value; K my_key; K my_message_key; MyMessageKeyWithBrokenKey(int i = 0, int v = 0): my_value((V)v), my_key(), my_message_key(index_to_key()(i)) { } void print_val() const { INFO("MyMessageKeyWithBrokenKey{"); print_my_value(my_message_key); INFO(","); print_my_value(my_value); INFO("}"); } operator int() const { return (int)my_value; } const K& key() const { return my_message_key; } }; template struct MyKeyWithBrokenMessageKey { V my_value; K my_key; MyKeyWithBrokenMessageKey(int i = 0, int v = 0): my_value((V)v), my_key(index_to_key()(i)) { } void print_val() const { INFO("MyKeyWithBrokenMessageKey{"); print_my_value(my_key); INFO(","); print_my_value(my_value); INFO("}"); } operator int() const { return (int)my_value; } K key() const { CHECK_MESSAGE( (false), "The method should never be called"); return K(); } }; template struct MyMessageKeyWithoutKeyMethod { V my_value; K my_message_key; MyMessageKeyWithoutKeyMethod(int i = 0, int v = 0): my_value((V)v), my_message_key(index_to_key()(i)) { } void print_val() const { INFO("MyMessageKeyWithoutKeyMethod{"); print_my_value(my_message_key); INFO(","); print_my_value(my_value); INFO("}"); } operator int() const { return (int)my_value; } //K key() const; // Do not define }; // Overload for MyMessageKeyWithoutKeyMethod template K key_from_message(const MyMessageKeyWithoutKeyMethod::type, V> &m) { return m.my_message_key; } // pattern for creating values in the tag_matching and key_matching, given an integer and the index in the tuple template struct make_thingie { TT operator()(int const &i) { return TT(i * (INDEX+1)); } }; template