cgma
ModelQueryEngine Class Reference

#include <ModelQueryEngine.hpp>

List of all members.

Classes

class  BeginQuery

Public Member Functions

 ~ModelQueryEngine ()
CubitStatus query_model (TopologyEntity &source_object, DagType target_type, DLIList< TopologyEntity * > &result_set)
CubitStatus query_model_and_append (TopologyEntity &source_object, DagType target_type, DLIList< TopologyEntity * > &result_set)
CubitStatus query_model (DLIList< TopologyEntity * > &source_set, DagType target_type, DLIList< TopologyEntity * > &result_set)
CubitStatus query_model_and_append (DLIList< TopologyEntity * > &source_set, DagType target_type, DLIList< TopologyEntity * > &result_set)
bool encountered (TopologyEntity *)

Static Public Member Functions

static ModelQueryEngineinstance ()
static void delete_instance ()

Protected Member Functions

CubitStatus query_append_children (TopologyEntity &source_object, DagType child_type, DLIList< TopologyEntity * > &result_set)
CubitStatus query_append_parents (TopologyEntity &source_object, DagType parent_type, DLIList< TopologyEntity * > &result_set)
void inc_query_call_stack ()
void dec_query_call_stack ()

Protected Attributes

int queryCallStackDepth
DLIList< TopologyEntity * > encounteredSet
DLIList< TopologyEntity * > intermediateNodeSets [2]

Private Member Functions

 ModelQueryEngine ()

Static Private Attributes

static ModelQueryEngineinstance_ = NULL

Friends

class ModelQueryEngine::BeginQuery

Detailed Description

Definition at line 75 of file ModelQueryEngine.hpp.


Constructor & Destructor Documentation

Definition at line 92 of file ModelQueryEngine.cpp.

{
   // Set static instance_ to zero to indicated that we are dead.
   instance_ = NULL;
}

Definition at line 112 of file ModelQueryEngine.cpp.


Member Function Documentation

static void ModelQueryEngine::delete_instance ( ) [inline, static]

Definition at line 89 of file ModelQueryEngine.hpp.

      {
        if(instance_)
          delete instance_;
        instance_ = NULL;
      }

Definition at line 322 of file ModelQueryEngine.cpp.

{
  if (node_ptr->encountered_)
    return true;
  
  encounteredSet.append(node_ptr);
  node_ptr->encountered_ = true;
  return false;
}

Definition at line 332 of file ModelQueryEngine.cpp.

Definition at line 74 of file ModelQueryEngine.cpp.

{
  if (instance_ == NULL)
  {
    instance_ = new ModelQueryEngine;
  }
  return instance_;
}
CubitStatus ModelQueryEngine::query_append_children ( TopologyEntity source_object,
DagType  child_type,
DLIList< TopologyEntity * > &  result_set 
) [protected]

Definition at line 231 of file ModelQueryEngine.cpp.

{
  BeginQuery lock;
  
  DagType current_type = source_object.dag_type();
  assert(current_type.is_valid() && target_type.is_valid());
  assert(current_type > target_type);
  
  intermediateNodeSets[0].clean_out();
  intermediateNodeSets[0].append(&source_object);
  int current_index = 0;
  
  while (current_type > target_type)
  {
    DLIList<TopologyEntity*>& current_set = intermediateNodeSets[ current_index];
    DLIList<TopologyEntity*>&    next_set = intermediateNodeSets[!current_index];
    
    next_set.clean_out();
    current_set.reset();
    for (int i = current_set.size(); i--; )
    {
      TopologyEntity* current_ptr = current_set.get_and_step();
      current_ptr->query_append_children(next_set);
    }

    current_index = !current_index;
    current_type--;
  }
  
  result_set += intermediateNodeSets[current_index];
  return CUBIT_SUCCESS;
}
CubitStatus ModelQueryEngine::query_append_parents ( TopologyEntity source_object,
DagType  parent_type,
DLIList< TopologyEntity * > &  result_set 
) [protected]

Definition at line 277 of file ModelQueryEngine.cpp.

{
  BeginQuery lock;
  
  DagType current_type = source_object.dag_type();
  assert(current_type.is_valid() && target_type.is_valid());
  assert(current_type < target_type);
  
  intermediateNodeSets[0].clean_out();
  intermediateNodeSets[0].append(&source_object);
  int current_index = 0;
  
  while (current_type < target_type)
  {
    DLIList<TopologyEntity*>& current_set = intermediateNodeSets[ current_index];
    DLIList<TopologyEntity*>&    next_set = intermediateNodeSets[!current_index];
    
    next_set.clean_out();
    current_set.reset();
    for (int i = current_set.size(); i--; )
    {
      TopologyEntity* current_ptr = current_set.get_and_step();
      current_ptr->query_append_parents(next_set);
    }

    current_index = !current_index;
    current_type++;
  }
  
  result_set += intermediateNodeSets[current_index];
  return CUBIT_SUCCESS;
}
CubitStatus ModelQueryEngine::query_model ( TopologyEntity source_object,
DagType  target_type,
DLIList< TopologyEntity * > &  result_set 
)

Definition at line 163 of file ModelQueryEngine.cpp.

{
  result_set.clean_out();
  return query_model_and_append( source_object, target_type, result_set );
}
CubitStatus ModelQueryEngine::query_model ( DLIList< TopologyEntity * > &  source_set,
DagType  target_type,
DLIList< TopologyEntity * > &  result_set 
)

Definition at line 182 of file ModelQueryEngine.cpp.

{
  result_set.clean_out();
  return query_model_and_append( source_set, target_type, result_set );
}
CubitStatus ModelQueryEngine::query_model_and_append ( TopologyEntity source_object,
DagType  target_type,
DLIList< TopologyEntity * > &  result_set 
)

Definition at line 126 of file ModelQueryEngine.cpp.

{
  BeginQuery lock;
  
  DagType source_type = source_object.dag_type();

  if (!source_type.is_valid() || !target_type.is_valid())
    return CUBIT_FAILURE;

  else if (source_type < target_type)
    return query_append_parents( source_object, target_type, result_set );

  else if (source_type > target_type)
    return query_append_children( source_object, target_type, result_set );  

  else // same type
  {
    assert(source_type == target_type);
    if (!encountered(&source_object))
      result_set.append(&source_object);
    return CUBIT_SUCCESS;
  }
}
CubitStatus ModelQueryEngine::query_model_and_append ( DLIList< TopologyEntity * > &  source_set,
DagType  target_type,
DLIList< TopologyEntity * > &  result_set 
)

Definition at line 201 of file ModelQueryEngine.cpp.

{
  BeginQuery lock;
  CubitStatus result = CUBIT_SUCCESS;
  
  source_set.reset();
  for (int i = source_set.size(); i--; )
  {
    TopologyEntity& source = *source_set.get_and_step();
    if (!query_model_and_append( source, target_type, result_set ))
      result = CUBIT_FAILURE;
  }
  
  return result;
}

Friends And Related Function Documentation

friend class ModelQueryEngine::BeginQuery [friend]

Definition at line 179 of file ModelQueryEngine.hpp.


Member Data Documentation

ModelQueryEngine * ModelQueryEngine::instance_ = NULL [static, private]

Definition at line 197 of file ModelQueryEngine.hpp.

Definition at line 184 of file ModelQueryEngine.hpp.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines