Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5966549
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:48:55+00:00 2026-05-22T19:48:55+00:00

I have defined a ‘vertex’ class which, when combined, form a graph. these vertices

  • 0

I have defined a ‘vertex’ class which, when combined, form a graph.
these vertices receive input on one end and produce output on the other (both of these sides can have 0, 1, or more ‘subscriptions’ of other instances of this vertex class)
The types for both the incoming and outgoing data are independent of each other and are specified as template parameters as these vertices must operate on all kinds of in/output types.

So in code this becomes:

template<class incomingDataType, class OutgoingDataType>
    class Vertex {...}

Before sending out the received data, a vertex can apply a filter function to transform/filter the data before sending it back out again to its list subscribers.
This function is declared as a pure virtual function as the functionality of it depends on the kind of specialization class inheriting from this virtual vertex base class.

This means the filter is declared as:

OutgoingDataType filter(incomingDataType data) = 0; 

Of course I want to link together multiple vertices to each other.
Consider this linking in its most simple form where each vertex’s input and output is connected to exactly one other vertex’s input/output:

(ClassX)vertex1(int) –> (int)vertex2(std::string) –> (std::string)vertex3(OtherClassOrType) –>…

With this in mind, the problem statement is as follows for the given example:
vertex2 must list vertex1 as a subscriber and subscribe itself to vertex3.
In order to keep track of all these subscriptions, a vertex keeps a set of pointers to all its publishers and subscribers:

template<class incomingDataType, class OutgoingDataType>
class Vertex {
....
bool subscribe(Vertex<OutgoingDataType, __DontCareType__>* subscriber);
OutgoingDataType filter(incomingDataType data) = 0; 
....
//set of 'outgoing vertices' - whom we provide with data
std::set< Vertex<OutgoingDataType, __DontCareType__>* >subscribers_;  
//set of 'incomming vertices' - providing us with data 
std::set< Vertex<__DontCareType__, incomingDataType>* >publishers_; 
}

A vertex subscribing to us needs to match its incoming data type with our outgoing data type but we don’t care about the subscriber’s outgoing data type as it does not concern us. The same applies for the incoming data type of our publishers.

Unfortunately I can’t seem to figure out how I can specify this. I’ve already fiddled with boost::any (won’t compile), void pointers (won’t compile), using function templates instead of class templates (won’t work due to virtual filter function)… but nothing I can think of works.

So in short, I’m looking for a way to have a ‘DontCareType‘ type as a template parameter, if that is possible at all, which is basically a way of saying “the template parameter I mark as ‘I don’t care’ can be of any type, because I don’t use its data anyway”

As a last resort to get a working solution, I’m also considering the option of using a kind of “VertexData” type, which must then be the base class of any incoming or outgoing data types used in the vertices. Would this be of any help?

Any other suggestions for making this feasible are of course also welcome.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T19:48:56+00:00Added an answer on May 22, 2026 at 7:48 pm

    You want to use run-time inheritance for this.

    template<typename T> struct InputVertex { ... };
    template<typename T> struct OutputVertex { ... };
    template<typename Incoming, typename Outgoing> struct Vertex 
    : public InputVertex<Incoming>, public OutputVertex<Outgoing> {
        std::set<InputVertex<Outgoing>*> outgoings;
    public:
        void RegisterFilter(InputVertex<Outgoing>* ptr) {
            outgoings.insert(ptr);
        }
        void RemoveFilter(InputVertex<Outgoing>* ptr) {
            outgoings.erase(ptr);
        }
        void Process(const std::vector<Incoming>& ref) {
            std::vector<Outgoing> output;
            // Transform
            for(auto ref : outgoings) {
                outgoings->Process(output);
            }
        }
    };
    

    In this case, the interface for incoming and outgoing is clearly separated, making it much easier to deal with the two independently. Excuse my use of C++0x’s range-based for.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have defined one Thickness resource in Window's resources collection which is set to
I have defined a class which represents a tree structure GeographicalUnits = Ext.extend(Ext.tree.TreePanel, {
I have defined an interface in C++, i.e. a class containing only pure virtual
I have an interface that I have defined in C++ which now needs to
Let's say we have defined a CSS class that is being applied to various
I have defined a record which has lots of fields with different types (integer,
I have a login.jsp page which contains a login form. Once logged in the
i have a input tag which is non editable, but some times i need
I have defined this Entity class, but it does not seem to save the
I have defined different states in my lexer, which change not depending on the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.