mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Decoupling
- Eliminated some calls to context.config from Task‥cpp, reducing the coupling. If context can be eliminated from Task.cpp, via statically initialized variables, then Taskwarrior and the task server can share Task.{ḩ,cpp} which would be an enormous saving in effort. (cherry picked from commit 215b03b1a7f47299a0d3e64331c7e3c962b4caf0)
This commit is contained in:
parent
a3f158d399
commit
c16a735040
4 changed files with 127 additions and 117 deletions
|
@ -138,10 +138,6 @@ int Context::initialize (int argc, const char** argv)
|
|||
// Apply rc overrides to Context::config, capturing raw args for later use.
|
||||
a3.apply_overrides ();
|
||||
|
||||
// Now that the final RC is in place, initialize the urgency coefficients
|
||||
// to speed the 'next' report.
|
||||
initializeUrgencyCoefficients ();
|
||||
|
||||
// Initialize the color rules, if necessary.
|
||||
if (color ())
|
||||
initializeColorRules ();
|
||||
|
@ -152,6 +148,9 @@ int Context::initialize (int argc, const char** argv)
|
|||
// Instantiate built-in column objects.
|
||||
Column::factory (columns);
|
||||
|
||||
// Static initialization to decouple code.
|
||||
staticInitialization ();
|
||||
|
||||
// Categorize all arguments one more time. THIS IS NECESSARY - it helps the
|
||||
// following inject_defaults method determine whether there needs to be a
|
||||
// default command assumed.
|
||||
|
@ -571,6 +570,47 @@ const std::vector <std::string> Context::getCommands () const
|
|||
return output;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// The 'Task' object, among others, is shared between projects. To make this
|
||||
// easier, it has been decoupled from Context.
|
||||
void Context::staticInitialization ()
|
||||
{
|
||||
Task::defaultProject = config.get ("default.project");
|
||||
Task::defaultPriority = config.get ("default.priority");
|
||||
Task::defaultDue = config.get ("default.due");
|
||||
Task::searchCaseSensitive = config.getBoolean ("search.case.sensitive");
|
||||
Task::regex = config.getBoolean ("regex");
|
||||
|
||||
std::map <std::string, Column*>::iterator i;
|
||||
for (i = columns.begin (); i != columns.end (); ++i)
|
||||
Task::attributes[i->first] = i->second->type ();
|
||||
|
||||
Task::urgencyPriorityCoefficient = config.getReal ("urgency.priority.coefficient");
|
||||
Task::urgencyProjectCoefficient = config.getReal ("urgency.project.coefficient");
|
||||
Task::urgencyActiveCoefficient = config.getReal ("urgency.active.coefficient");
|
||||
Task::urgencyScheduledCoefficient = config.getReal ("urgency.scheduled.coefficient");
|
||||
Task::urgencyWaitingCoefficient = config.getReal ("urgency.waiting.coefficient");
|
||||
Task::urgencyBlockedCoefficient = config.getReal ("urgency.blocked.coefficient");
|
||||
Task::urgencyAnnotationsCoefficient = config.getReal ("urgency.annotations.coefficient");
|
||||
Task::urgencyTagsCoefficient = config.getReal ("urgency.tags.coefficient");
|
||||
Task::urgencyNextCoefficient = config.getReal ("urgency.next.coefficient");
|
||||
Task::urgencyDueCoefficient = config.getReal ("urgency.due.coefficient");
|
||||
Task::urgencyBlockingCoefficient = config.getReal ("urgency.blocking.coefficient");
|
||||
Task::urgencyAgeCoefficient = config.getReal ("urgency.age.coefficient");
|
||||
|
||||
// Tag- and project-specific coefficients.
|
||||
std::vector <std::string> all;
|
||||
config.all (all);
|
||||
|
||||
std::vector <std::string>::iterator var;
|
||||
for (var = all.begin (); var != all.end (); ++var)
|
||||
{
|
||||
if (var->substr (0, 13) == "urgency.user." ||
|
||||
var->substr (0, 12) == "urgency.uda.")
|
||||
Task::coefficients[*var] = config.getReal (*var);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Context::assumeLocations ()
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue