Back to index

unity  6.0.0
Public Member Functions | Static Public Member Functions | Private Attributes
unity::dash::HomeLens::CategoryRegistry Class Reference
Collaboration diagram for unity::dash::HomeLens::CategoryRegistry:
Collaboration graph
[legend]

List of all members.

Public Member Functions

int FindCategoryOffset (DeeModel *model, unsigned int source_cat_offset)
int FindCategoryOffset (const gchar *display_name)
void RegisterCategoryOffset (DeeModel *model, unsigned int source_cat_offset, const gchar *display_name, unsigned int target_cat_offset)
void AssociateCategoryOffset (DeeModel *model, unsigned int source_cat_offset, unsigned int target_cat_offset)
bool CheckDirty ()
 Returns true and resets the dirty state if the registry was dirty.

Static Public Member Functions

 CategoryRegistry (HomeLens *owner)

Private Attributes

std::map< std::string,
unsigned int > 
reg_by_id_
std::map< std::string,
unsigned int > 
reg_by_display_name_
bool is_dirty_
HomeLensowner_

Detailed Description

Definition at line 52 of file HomeLens.cpp.


Constructor & Destructor Documentation

Definition at line 55 of file HomeLens.cpp.

    : is_dirty_(false)
    , owner_(owner) {}

Member Function Documentation

void unity::dash::HomeLens::CategoryRegistry::AssociateCategoryOffset ( DeeModel *  model,
unsigned int  source_cat_offset,
unsigned int  target_cat_offset 
) [inline]

Definition at line 148 of file HomeLens.cpp.

  {
    glib::String c_id(g_strdup_printf("%u+%p", source_cat_offset, model));

    std::map<std::string,unsigned int>::iterator i = reg_by_id_.find(c_id);
    if (i != reg_by_id_.end())
    {
      LOG_ERROR(logger) << "Category '" << c_id << "' already registered!";
      return;
    }

    reg_by_id_[c_id] = target_cat_offset;
  }

Returns true and resets the dirty state if the registry was dirty.

When you've checked a dirty registry you must either clear the merged results model or recalibrate all category offset in it (and Unity probably wont support the latter?).

Definition at line 170 of file HomeLens.cpp.

  {
    return is_dirty_ ? (is_dirty_ = false, true) : false;
  }
int unity::dash::HomeLens::CategoryRegistry::FindCategoryOffset ( DeeModel *  model,
unsigned int  source_cat_offset 
) [inline]

Definition at line 59 of file HomeLens.cpp.

  {
    glib::String c_id(g_strdup_printf("%u+%p", source_cat_offset, model));
    std::map<std::string,unsigned int>::iterator i = reg_by_id_.find(c_id);

    if (i != reg_by_id_.end())
      return i->second;

    return -1;
  }
int unity::dash::HomeLens::CategoryRegistry::FindCategoryOffset ( const gchar *  display_name) [inline]

Definition at line 70 of file HomeLens.cpp.

    {
      std::map<std::string,unsigned int>::iterator i =
                                        reg_by_display_name_.find(display_name);
      if (i != reg_by_display_name_.end())
        return i->second;

      return -1;
    }
void unity::dash::HomeLens::CategoryRegistry::RegisterCategoryOffset ( DeeModel *  model,
unsigned int  source_cat_offset,
const gchar *  display_name,
unsigned int  target_cat_offset 
) [inline]

Definition at line 81 of file HomeLens.cpp.

  {
    glib::String c_id(g_strdup_printf("%u+%p", source_cat_offset, model));

    std::map<std::string,unsigned int>::iterator i = reg_by_id_.find(c_id);
    if (i != reg_by_id_.end())
    {
      LOG_ERROR(logger) << "Category '" << c_id << "' already registered!";
      return;
    }

    if (display_name != NULL)
    {
      i = reg_by_display_name_.find(display_name);
      if (i != reg_by_display_name_.end())
      {
        LOG_ERROR(logger) << "Category '" << display_name << "' already registered!";
        return;
      }
    }

    /* Any existing categories with offsets >= target_cat_offset must be
     * pushed up. Update both maps by id and display name */
    std::map<std::string,unsigned int>::iterator end = reg_by_id_.end();
    for (i = reg_by_id_.begin(); i != end; i++)
    {
      if (i->second >= target_cat_offset)
      {
        i->second = i->second + 1;
        is_dirty_ = true;
      }
    }

    for (i = reg_by_display_name_.begin(), end = reg_by_display_name_.end(); i != end; i++)
    {
      if (i->second >= target_cat_offset)
      {
        i->second = i->second + 1;
        is_dirty_ = true;
      }
    }

    reg_by_id_[c_id] = target_cat_offset;

    /* Callers pass a NULL display_name when they already have a category
     * with the right display registered */
    if (display_name != NULL)
    {
      reg_by_display_name_[display_name] = target_cat_offset;
      LOG_DEBUG(logger) << "Registered category '" << display_name
                        << "' with source offset " << source_cat_offset
                        << " and target offset " << target_cat_offset
                        << ". Id " << c_id;
    }
    else
    {
      LOG_DEBUG(logger) << "Registered category with source offset "
                        << source_cat_offset << " and target offset "
                        << target_cat_offset << ". Id " << c_id;
    }
  }

Member Data Documentation

Definition at line 178 of file HomeLens.cpp.

Definition at line 179 of file HomeLens.cpp.

std::map<std::string,unsigned int> unity::dash::HomeLens::CategoryRegistry::reg_by_display_name_ [private]

Definition at line 177 of file HomeLens.cpp.

std::map<std::string,unsigned int> unity::dash::HomeLens::CategoryRegistry::reg_by_id_ [private]

Definition at line 176 of file HomeLens.cpp.


The documentation for this class was generated from the following file: